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);
}
}
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);
}
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);
}
}
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);
}
}
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) != '<');
}
Aggregations