use of org.apache.handlers.AddNumbersService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithDOMSourcMessageMode.
@Test
public void testInvokeWithDOMSourcMessageMode() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
assertNotNull(service);
Dispatch<DOMSource> disp = service.createDispatch(portName, DOMSource.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandler handler = new TestHandler();
TestSOAPHandler soapHandler = new TestSOAPHandler();
addHandlersProgrammatically(disp, handler, soapHandler);
InputStream is = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is);
soapReq.saveChanges();
DOMSource domReqMessage = new DOMSource(soapReq.getSOAPPart());
DOMSource response = disp.invoke(domReqMessage);
// XMLUtils.writeTo(response, System.out);
assertNotNull(response);
}
use of org.apache.handlers.AddNumbersService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithSOAPMessageMessageMode.
@Test
public void testInvokeWithSOAPMessageMessageMode() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
assertNotNull(service);
Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
setAddress(disp, addNumbersAddress);
TestHandler handler = new TestHandler();
TestSOAPHandler soapHandler = new TestSOAPHandler();
addHandlersProgrammatically(disp, handler, soapHandler);
InputStream is2 = this.getClass().getResourceAsStream("resources/GreetMeDocLiteralReq.xml");
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage soapReq = factory.createMessage(null, is2);
SOAPMessage response = disp.invoke(soapReq);
assertNotNull(response);
// response.writeTo(System.out);
}
use of org.apache.handlers.AddNumbersService in project cxf by apache.
the class DispatchHandlerInvocationTest method testInvokeWithJAXBPayloadMode.
@Test
public void testInvokeWithJAXBPayloadMode() throws Exception {
URL wsdl = getClass().getResource("/wsdl/addNumbers.wsdl");
assertNotNull(wsdl);
AddNumbersService service = new AddNumbersService(wsdl, serviceName);
assertNotNull(service);
JAXBContext jc = JAXBContext.newInstance("org.apache.handlers.types");
Dispatch<Object> disp = service.createDispatch(portName, jc, Service.Mode.PAYLOAD);
setAddress(disp, addNumbersAddress);
TestHandler handler = new TestHandler();
TestSOAPHandler soapHandler = new TestSOAPHandler();
addHandlersProgrammatically(disp, handler, soapHandler);
org.apache.handlers.types.AddNumbers req = new org.apache.handlers.types.AddNumbers();
req.setArg0(10);
req.setArg1(20);
ObjectFactory factory = new ObjectFactory();
JAXBElement<AddNumbers> e = factory.createAddNumbers(req);
JAXBElement<?> response = (JAXBElement<?>) disp.invoke(e);
assertNotNull(response);
AddNumbersResponse value = (AddNumbersResponse) response.getValue();
assertEquals(222, value.getReturn());
}
Aggregations