Search in sources :

Example 1 with JavaCallInfo

use of com.oracle.webservices.api.databinding.JavaCallInfo in project Payara by payara.

the class MonitoringPipe method process.

@Override
public Packet process(Packet pipeRequest) {
    // If it is a JBI request then skip the monitoring logic. This is done
    // as HTTPServletRequest/Response is not available when the invocation
    // is from JavaEE service engine.
    String delegateClassName = pipeRequest.webServiceContextDelegate.getClass().getName();
    if (delegateClassName.equals("com.sun.enterprise.jbi.serviceengine." + "bridge.transport.NMRServerConnection")) {
        return next.process(pipeRequest);
    }
    // No monitoring available for restful services
    if ("http://www.w3.org/2004/08/wsdl/http".equals(endpoint.getProtocolBinding())) {
        return next.process(pipeRequest);
    }
    HttpServletRequest httpRequest = (HttpServletRequest) pipeRequest.get(SERVLET_REQUEST);
    HttpServletResponse httpResponse = (HttpServletResponse) pipeRequest.get(SERVLET_RESPONSE);
    JAXWSEndpointImpl endpointTracer = getEndpointTracer(httpRequest);
    SOAPMessageContextImpl soapMessageContext = new SOAPMessageContextImpl(pipeRequest);
    InvocationManager invocationManager = Globals.get(InvocationManager.class);
    JavaCallInfo javaCallInfo = getJavaCallInfo(pipeRequest);
    try {
        pushWebServiceMethod(invocationManager, javaCallInfo);
        firePreInvocation(httpRequest, pipeRequest, endpointTracer, soapMessageContext, javaCallInfo);
        // Copy pipe request, since when the endpoint is NOT an EJB, it's body will be emptied after the service invocation
        Packet originalPipeRequest = pipeRequest.copy(true);
        Packet pipeResponse = next.process(pipeRequest);
        firePostInvocation(httpResponse, pipeResponse, originalPipeRequest, endpointTracer, soapMessageContext);
        return pipeResponse;
    } finally {
        popWebServiceMethod(invocationManager, javaCallInfo);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Packet(com.sun.xml.ws.api.message.Packet) InvocationManager(org.glassfish.api.invocation.InvocationManager) HttpServletResponse(javax.servlet.http.HttpServletResponse) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) JAXWSEndpointImpl(org.glassfish.webservices.monitoring.JAXWSEndpointImpl)

Example 2 with JavaCallInfo

use of com.oracle.webservices.api.databinding.JavaCallInfo in project metro-jax-ws by eclipse-ee4j.

the class SAAJMessageWrapperTest method testMTOM_riSaaj.

public void testMTOM_riSaaj() throws Exception {
    // client creates request
    MessageContext clientRequest = databinding.serializeRequest(clientCall);
    // client writes request to OutputStream
    ByteArrayOutputStream clientOut = new ByteArrayOutputStream();
    ContentType cliCt = clientRequest.writeTo(clientOut);
    // com.sun.xml.ws.api.pipe.ContentType cliCt = ((com.sun.xml.ws.api.databinding.Databinding)databinding).
    // encode((Packet)clientRequest, clientOut);
    // System.out.println("==== Client Request " + cliCt.getContentType() + " " + cliCt.getSOAPActionHeader() );
    // System.out.println(new String(clientOut.toByteArray()) + "\r\n\r\n");
    // client sends request to server
    ByteArrayInputStream serverIn = new ByteArrayInputStream(clientOut.toByteArray());
    // server decodes request to Packet
    MessageContext serverRequest = mcf.createContext(serverIn, cliCt.getContentType());
    // deprecated way to create/decode MC/Packet from inputStream
    // com.sun.xml.ws.api.message.Packet serverRequest = new com.sun.xml.ws.api.message.Packet();
    // ((com.sun.xml.ws.api.databinding.Databinding)databinding).decode(serverIn, cliCt.getContentType(), serverRequest);
    // setup JRF env ...
    // ContainerResolver.setInstance(new JRFContainerResolver());
    // server coverts request to saaj SOAPMessage
    SOAPMessage saajReq1 = serverRequest.getAsSOAPMessage();
    assertEquals("wrong attachment count", 1, saajReq1.countAttachments());
    // System.out.println("==== serverRequest.getSOAPMessage() 1 " + saajReq1);
    // Write the SOAPMessage multiple times result in different message boundary -
    // {
    // saajReq1 = serverRequest.getSOAPMessage();
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + saajReq1);
    // ByteArrayOutputStream saajReq1Out = new ByteArrayOutputStream();
    // saajReq1.writeTo(saajReq1Out);
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + new String(saajReq1Out.toByteArray()));
    // }
    // {
    // saajReq1 = serverRequest.getSOAPMessage();
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + saajReq1);
    // ByteArrayOutputStream saajReq1Out = new ByteArrayOutputStream();
    // saajReq1.writeTo(saajReq1Out);
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + new String(saajReq1Out.toByteArray()));
    // }
    // {
    // saajReq1 = serverRequest.getSOAPMessage();
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + saajReq1);
    // ByteArrayOutputStream saajReq1Out = new ByteArrayOutputStream();
    // saajReq1.writeTo(saajReq1Out);
    // System.out.println("\r\n==== serverRequest.getSOAPMessage() 1 " + new String(saajReq1Out.toByteArray()));
    // }
    // !! NPE if the following line of serverRequest.setMessage(...) is removed
    // ((Packet)serverRequest).setMessage(new com.sun.xml.ws.message.saaj.SAAJMessage(saajReq1));
    SOAPMessage saajReq2 = ((Packet) serverRequest).getMessage().readAsSOAPMessage();
    SOAPMessage saajReq3 = serverRequest.getAsSOAPMessage();
    SOAPMessage saajReq4 = ((Packet) serverRequest).getMessage().readAsSOAPMessage();
    // System.out.println("==== serverRequest.getSOAPMessage() 2 " + saajReq2);
    assertTrue(saajReq1 == saajReq2);
    assertTrue(saajReq3 == saajReq2);
    assertTrue(saajReq4 == saajReq3);
    // !! Do we need orassaj-XMLStreamReaderEx if the databinding can descerialize orasaaj SOAPMessagae as inline?
    JavaCallInfo serverCall = databinding.deserializeRequest(serverRequest);
    serverCall.setReturnValue(serverCall.getParameters()[0]);
    // server creates response
    MessageContext serverResponse = databinding.serializeResponse(serverCall);
    // server coverts response to saaj SOAPMessage
    SOAPMessage saajRes1 = serverResponse.getAsSOAPMessage();
    // System.out.println("==== serverResponse.getSOAPMessage() 1 " + saajRes1);
    // !! server coverts response to saaj SOAPMessage again but get another new saaj SOAPMessage
    SOAPMessage saajRes2 = ((Packet) serverResponse).getMessage().readAsSOAPMessage();
    SOAPMessage saajRes3 = serverResponse.getAsSOAPMessage();
    SOAPMessage saajRes4 = ((Packet) serverResponse).getMessage().readAsSOAPMessage();
    // System.out.println("==== serverResponse.getSOAPMessage() 2 " + saajRes2);
    assertTrue(saajRes1 == saajRes2);
    // !! Following line keeps the same saaj message but removes mtom effect on response
    // ((Packet)serverResponse).setMessage(new com.sun.xml.ws.message.saaj.SAAJMessage(saajRes1));
    SOAPMessage saajRes5 = serverResponse.getAsSOAPMessage();
    assertTrue(saajRes3 == saajRes2);
    assertTrue(saajRes3 == saajRes4);
    assertTrue(saajRes4 == saajRes5);
    // System.out.println("==== serverResponse.getSOAPMessage() 3 " + saajRes3);
    // {
    // ByteArrayOutputStream serverOut = new ByteArrayOutputStream();
    // //TODO serverResponse.writeTo(serverOut);
    // com.sun.xml.ws.api.pipe.ContentType resCt = ((com.sun.xml.ws.api.databinding.Databinding)databinding).
    // encode((com.sun.xml.ws.api.message.Packet)serverResponse, serverOut);
    // System.out.println("==== Server Response 1 " + resCt.getContentType() + " " + resCt.getSOAPActionHeader() );
    // System.out.println(new String(serverOut.toByteArray()) + "\r\n\r\n");
    // }
    // {
    // ByteArrayOutputStream serverOut = new ByteArrayOutputStream();
    // //TODO serverResponse.writeTo(serverOut);
    // com.sun.xml.ws.api.pipe.ContentType resCt = ((com.sun.xml.ws.api.databinding.Databinding)databinding).
    // encode((com.sun.xml.ws.api.message.Packet)serverResponse, serverOut);
    // System.out.println("==== Server Response 2 " + resCt.getContentType() + " " + resCt.getSOAPActionHeader() );
    // System.out.println(new String(serverOut.toByteArray()) + "\r\n\r\n");
    // }
    ByteArrayOutputStream serverOut = new ByteArrayOutputStream();
    ContentType resCt = serverResponse.writeTo(serverOut);
    // com.sun.xml.ws.api.pipe.ContentType resCt = ((com.sun.xml.ws.api.databinding.Databinding)databinding).
    // encode((com.sun.xml.ws.api.message.Packet)serverResponse, serverOut);
    // System.out.println("==== Server Response x " + resCt.getContentType() + " " + resCt.getSOAPActionHeader() );
    // System.out.println(new String(serverOut.toByteArray()) + "\r\n\r\n");
    // server sends response to client
    ByteArrayInputStream clientIn = new ByteArrayInputStream(serverOut.toByteArray());
    MessageContext clientResponse = mcf.createContext(clientIn, resCt.getContentType());
    // com.sun.xml.ws.api.message.Packet clientResponse = new com.sun.xml.ws.api.message.Packet();
    // ((com.sun.xml.ws.api.databinding.Databinding)databinding).decode(clientIn, resCt.getContentType(), clientResponse);
    clientCall = databinding.deserializeResponse(clientResponse, clientCall);
    String res = new String((byte[]) clientCall.getReturnValue());
    // System.out.println("response " + res);
    assertEquals(res, reqStr);
}
Also used : ContentType(com.oracle.webservices.api.message.ContentType) ByteArrayInputStream(java.io.ByteArrayInputStream) MessageContext(com.oracle.webservices.api.message.MessageContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) SOAPMessage(jakarta.xml.soap.SOAPMessage)

Example 3 with JavaCallInfo

use of com.oracle.webservices.api.databinding.JavaCallInfo in project metro-jax-ws by eclipse-ee4j.

the class WrapperNSTest method testWrapperNS.

public void testWrapperNS() throws Exception {
    Class<?> sei = MyHelloRPC.class;
    DatabindingFactory fac = DatabindingFactory.newInstance();
    Databinding.Builder b = fac.createBuilder(sei, null);
    DatabindingModeFeature dbf = new DatabindingModeFeature("eclipselink.jaxb");
    WebServiceFeature[] f = { dbf };
    b.feature(f);
    b.serviceName(new QName("http://echo.org/", "helloService"));
    b.portName(new QName("http://echo.org/", "helloPort"));
    Databinding db = b.build();
    {
        Method method = findMethod(sei, "echoString");
        Object[] args = { "test" };
        JavaCallInfo call = db.createJavaCallInfo(method, args);
        MessageContext mc = db.serializeRequest(call);
        SOAPMessage msg = mc.getSOAPMessage();
        // System.out.println("------------------ eclipselink");
        // msg.writeTo(System.out);
        // System.out.println();
        Node n = msg.getSOAPBody().getChildNodes().item(0);
        // System.out.println("num of attributes is: "+
        // n.getAttributes().getLength());
        assertTrue(n.getAttributes().getLength() == 1);
    }
}
Also used : DatabindingFactory(com.oracle.webservices.api.databinding.DatabindingFactory) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) Method(java.lang.reflect.Method) SOAPMessage(jakarta.xml.soap.SOAPMessage) Databinding(com.oracle.webservices.api.databinding.Databinding) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) MessageContext(com.oracle.webservices.api.message.MessageContext)

Example 4 with JavaCallInfo

use of com.oracle.webservices.api.databinding.JavaCallInfo in project metro-jax-ws by eclipse-ee4j.

the class WrapperNSTest method testWrapperNS_JAXBRI.

public void testWrapperNS_JAXBRI() throws Exception {
    Class<?> sei = MyHelloRPC.class;
    DatabindingFactory fac = DatabindingFactory.newInstance();
    Databinding.Builder b = fac.createBuilder(sei, null);
    DatabindingModeFeature dbf = new DatabindingModeFeature("glassfish.jaxb");
    WebServiceFeature[] f = { dbf };
    b.feature(f);
    b.serviceName(new QName("http://echo.org/", "helloService"));
    b.portName(new QName("http://echo.org/", "helloPort"));
    Databinding db = b.build();
    {
        Method method = findMethod(sei, "echoString");
        Object[] args = { "test" };
        JavaCallInfo call = db.createJavaCallInfo(method, args);
        MessageContext mc = db.serializeRequest(call);
        SOAPMessage msg = mc.getSOAPMessage();
        // System.out.println("------------------ glassfish");
        // msg.writeTo(System.out);
        // System.out.println();
        Node n = msg.getSOAPBody().getChildNodes().item(0);
        // System.out.println("num of attributes is: "+
        // n.getAttributes().getLength());
        assertTrue(n.getAttributes().getLength() == 1);
    }
}
Also used : DatabindingFactory(com.oracle.webservices.api.databinding.DatabindingFactory) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) DatabindingModeFeature(com.oracle.webservices.api.databinding.DatabindingModeFeature) Method(java.lang.reflect.Method) SOAPMessage(jakarta.xml.soap.SOAPMessage) Databinding(com.oracle.webservices.api.databinding.Databinding) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) MessageContext(com.oracle.webservices.api.message.MessageContext)

Example 5 with JavaCallInfo

use of com.oracle.webservices.api.databinding.JavaCallInfo in project metro-jax-ws by eclipse-ee4j.

the class SwaMimeAttachmentTest method testAttachmentContentId.

public void testAttachmentContentId() throws Exception {
    WSDLPort wsdlPort = getWSDLPort(getResource("WSW2JDLSwaTestService.wsdl"));
    Class proxySEIClass = SwaTest1.class;
    WebServiceFeature[] f = { databindingMode() };
    DatabindingConfig cliConfig = new DatabindingConfig();
    cliConfig.setContractClass(proxySEIClass);
    cliConfig.setFeatures(f);
    cliConfig.setWsdlPort(wsdlPort);
    cliConfig.setWsdlPort(wsdlPort);
    cliConfig.getMappingInfo().setServiceName(new QName("http://SwaTestService.org/wsdl", "WSIDLSwaTestService"));
    Databinding cli = (Databinding) factory.createRuntime(cliConfig);
    URL url1 = getResource("attach.text");
    URL url2 = getResource("attach.html");
    URL url3 = getResource("attach.xml");
    URL url4 = getResource("attach.jpeg1");
    URL url5 = getResource("attach.jpeg2");
    DataHandler dh1 = new DataHandler(url1);
    DataHandler dh2 = new DataHandler(url2);
    DataHandler dh3 = new DataHandler(url3);
    // DataHandler dh4 = new DataHandler(url4);
    // DataHandler dh5 = new DataHandler(url5);
    jakarta.xml.ws.Holder<jakarta.activation.DataHandler> attach1 = new jakarta.xml.ws.Holder<jakarta.activation.DataHandler>();
    attach1.value = dh1;
    jakarta.xml.ws.Holder<jakarta.activation.DataHandler> attach2 = new jakarta.xml.ws.Holder<jakarta.activation.DataHandler>();
    attach2.value = dh2;
    jakarta.xml.ws.Holder<javax.xml.transform.Source> attach3 = new jakarta.xml.ws.Holder<javax.xml.transform.Source>();
    attach3.value = new StreamSource(dh3.getInputStream());
    jakarta.xml.ws.Holder<java.awt.Image> attach4 = new jakarta.xml.ws.Holder<java.awt.Image>();
    jakarta.xml.ws.Holder<java.awt.Image> attach5 = new jakarta.xml.ws.Holder<java.awt.Image>();
    attach4.value = javax.imageio.ImageIO.read(url4);
    attach5.value = javax.imageio.ImageIO.read(url5);
    VoidRequest request = new VoidRequest();
    Object[] args = { request, attach1, attach2, attach3, attach4, attach5 };
    Method method = findMethod(proxySEIClass, "echoAllAttachmentTypes");
    JavaCallInfo cliCall = cli.createJavaCallInfo(method, args);
    Packet cliSoapReq = (Packet) cli.serializeRequest(cliCall);
    SOAPMessageContextImpl smc = new SOAPMessageContextImpl(null, cliSoapReq, null);
    Map<String, DataHandler> smcAtts1 = (Map<String, DataHandler>) smc.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    smc.put(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS, smcAtts1);
    assertEquals(5, smcAtts1.size());
    for (String cid : smcAtts1.keySet()) assertTrue(cid.charAt(0) != '<');
    for (com.sun.xml.ws.api.message.Attachment a : cliSoapReq.getMessage().getAttachments()) assertTrue(a.getContentId().charAt(0) != '<');
    Object s1 = cliSoapReq.getAsSOAPMessage();
    Object s2 = smc.getMessage();
    assertTrue(s1 == s2);
    for (com.sun.xml.ws.api.message.Attachment a : cliSoapReq.getMessage().getAttachments()) assertTrue(a.getContentId().charAt(0) != '<');
    // {
    // Map<String, DataHandler> atts = (Map<String, DataHandler>) smc.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    // AttachmentSet attSet = cliSoapReq.getMessage().getAttachments();
    // for(String cid : atts.keySet()){
    // if (attSet.get(cid) == null) {  // Otherwise we would be adding attachments twice
    // Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
    // attSet.add(att);
    // }
    // }
    // }
    Map<String, DataHandler> smcAtts2 = (Map<String, DataHandler>) smc.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
    assertEquals(5, smcAtts1.size());
    for (String cid : smcAtts2.keySet()) assertTrue(cid.charAt(0) != '<');
}
Also used : DataHandler(jakarta.activation.DataHandler) Image(java.awt.Image) URL(java.net.URL) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort) Databinding(com.sun.xml.ws.api.databinding.Databinding) Attachment(com.sun.xml.ws.api.message.Attachment) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) Packet(com.sun.xml.ws.api.message.Packet) QName(javax.xml.namespace.QName) StreamSource(javax.xml.transform.stream.StreamSource) Method(java.lang.reflect.Method) SOAPMessageContextImpl(com.sun.xml.ws.handler.SOAPMessageContextImpl) DatabindingConfig(com.sun.xml.ws.api.databinding.DatabindingConfig) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) HashMap(java.util.HashMap) Map(java.util.Map) MailcapCommandMap(jakarta.activation.MailcapCommandMap) CommandMap(jakarta.activation.CommandMap)

Aggregations

JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)10 Packet (com.sun.xml.ws.api.message.Packet)6 MessageContext (com.oracle.webservices.api.message.MessageContext)4 SOAPMessage (jakarta.xml.soap.SOAPMessage)4 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)4 Method (java.lang.reflect.Method)4 QName (javax.xml.namespace.QName)4 Databinding (com.oracle.webservices.api.databinding.Databinding)3 DatabindingFactory (com.oracle.webservices.api.databinding.DatabindingFactory)2 DatabindingModeFeature (com.oracle.webservices.api.databinding.DatabindingModeFeature)2 Databinding (com.sun.xml.ws.api.databinding.Databinding)2 DatabindingConfig (com.sun.xml.ws.api.databinding.DatabindingConfig)2 Attachment (com.sun.xml.ws.api.message.Attachment)2 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)2 SOAPMessageContextImpl (com.sun.xml.ws.handler.SOAPMessageContextImpl)2 DispatchException (com.sun.xml.ws.wsdl.DispatchException)2 CommandMap (jakarta.activation.CommandMap)2 DataHandler (jakarta.activation.DataHandler)2 MailcapCommandMap (jakarta.activation.MailcapCommandMap)2 Image (java.awt.Image)2