Search in sources :

Example 6 with AddNumbers

use of org.apache.handlers.types.AddNumbers 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());
}
Also used : AddNumbersService(org.apache.handlers.AddNumbersService) JAXBContext(javax.xml.bind.JAXBContext) AddNumbersResponse(org.apache.handlers.types.AddNumbersResponse) JAXBElement(javax.xml.bind.JAXBElement) URL(java.net.URL) ObjectFactory(org.apache.handlers.types.ObjectFactory) AddNumbers(org.apache.handlers.types.AddNumbers) AddNumbers(org.apache.handlers.types.AddNumbers) Test(org.junit.Test)

Aggregations

AddNumbers (org.apache.handlers.types.AddNumbers)6 JAXBContext (javax.xml.bind.JAXBContext)5 JAXBElement (javax.xml.bind.JAXBElement)5 ObjectFactory (org.apache.handlers.types.ObjectFactory)4 JAXBException (javax.xml.bind.JAXBException)3 LogicalMessage (javax.xml.ws.LogicalMessage)3 ProtocolException (javax.xml.ws.ProtocolException)3 AddNumbersResponse (org.apache.handlers.types.AddNumbersResponse)3 Source (javax.xml.transform.Source)2 WebServiceException (javax.xml.ws.WebServiceException)2 Test (org.junit.Test)2 URL (java.net.URL)1 LogicalMessageContextImpl (org.apache.cxf.jaxws.handler.logical.LogicalMessageContextImpl)1 LogicalMessageImpl (org.apache.cxf.jaxws.handler.logical.LogicalMessageImpl)1 Exchange (org.apache.cxf.message.Exchange)1 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)1 Message (org.apache.cxf.message.Message)1 MessageImpl (org.apache.cxf.message.MessageImpl)1 AddNumbersService (org.apache.handlers.AddNumbersService)1 Before (org.junit.Before)1