use of com.oracle.webservices.api.databinding.Databinding in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageWrapperTest method setUp.
public void setUp() {
Class<?> proxySEI = MtomSEI.class;
DatabindingFactory dbfac = DatabindingFactory.newInstance();
Databinding.Builder builder = dbfac.createBuilder(proxySEI, null);
builder.serviceName(new QName("http://example.org", "MtomTestService"));
builder.portName(new QName("http://example.org", "MtomTestPort"));
builder.feature(mtomf);
databinding = builder.build();
mcf = MessageContextFactory.createFactory(mtomf);
Method method = findMethod(proxySEI, "echoByteArray");
byte[] req = reqStr.getBytes();
Object[] args = { req };
clientCall = databinding.createJavaCallInfo(method, args);
}
use of com.oracle.webservices.api.databinding.Databinding 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.Databinding 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.Databinding in project metro-jax-ws by eclipse-ee4j.
the class SAAJMessageWrapperTest method XtestMTOM_oraSaaj.
public void XtestMTOM_oraSaaj() throws Exception {
// client creates request
MessageContext clientRequest = databinding.serializeRequest(clientCall);
// client writes request to OutputStream
// TODO databinding bug - fixed
// clientRequest.writeTo(clientOut);
ByteArrayOutputStream clientOut = new ByteArrayOutputStream();
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());
// setup JRF env ...
// ContainerResolver.setInstance(new JRFContainerResolver());
// server coverts request to saaj SOAPMessage
SOAPMessage saajReq1 = serverRequest.getSOAPMessage();
System.out.println("==== serverRequest.getSOAPMessage() 1 " + saajReq1);
// !! NPE if getSOAPMessage() more than one time
// SOAPMessage saajReq2 = serverRequest.getSOAPMessage();
// System.out.println("==== serverRequest.getSOAPMessage() 2 " + saajReq2);
// !! NPE if the following line of serverRequest.setMessage(...) is removed
((Packet) serverRequest).setMessage(new com.sun.xml.ws.message.saaj.SAAJMessage(saajReq1));
SOAPMessage saajReq2 = serverRequest.getSOAPMessage();
System.out.println("==== serverRequest.getSOAPMessage() 2 " + saajReq2);
// !! 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.getSOAPMessage();
System.out.println("==== serverResponse.getSOAPMessage() 1 " + saajRes1);
// !! server coverts response to saaj SOAPMessage again but get another new saaj SOAPMessage
SOAPMessage saajRes2 = serverResponse.getSOAPMessage();
System.out.println("==== serverResponse.getSOAPMessage() 2 " + 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 saajRes3 = serverResponse.getSOAPMessage();
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();
// 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 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);
}
Aggregations