Search in sources :

Example 1 with MessageReplayObserver

use of org.apache.cxf.jaxws.MessageReplayObserver in project cxf by apache.

the class DispatchTest method testSOAPPBindingNullMessage.

@Test
public void testSOAPPBindingNullMessage() throws Exception {
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
    try {
        // Send a null message
        disp.invoke(null);
    } catch (SOAPFaultException e) {
        // Passed
        return;
    }
    fail("SOAPFaultException was not thrown");
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) JAXBContext(javax.xml.bind.JAXBContext) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) URL(java.net.URL) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with MessageReplayObserver

use of org.apache.cxf.jaxws.MessageReplayObserver in project cxf by apache.

the class DispatchTest method testDOMSource.

@Test
public void testDOMSource() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), SERVICE_NAME, null);
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
    Document doc = StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
    DOMSource source = new DOMSource(doc);
    Source res = disp.invoke(source);
    assertNotNull(res);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) Document(org.w3c.dom.Document) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 3 with MessageReplayObserver

use of org.apache.cxf.jaxws.MessageReplayObserver in project cxf by apache.

the class DispatchTest method testJAXB.

@Test
public void testJAXB() throws Exception {
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
    URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(wsdl);
    SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
    assertNotNull(service);
    JAXBContext jc = JAXBContext.newInstance("org.apache.hello_world_soap_http.types");
    Dispatch<Object> disp = service.createDispatch(PORT_NAME, jc, Service.Mode.PAYLOAD);
    SayHi s = new SayHi();
    Object response = disp.invoke(s);
    assertNotNull(response);
    assertTrue(response instanceof SayHiResponse);
}
Also used : SOAPService(org.apache.hello_world_soap_http.SOAPService) SayHi(org.apache.hello_world_soap_http.types.SayHi) SayHiResponse(org.apache.hello_world_soap_http.types.SayHiResponse) JAXBContext(javax.xml.bind.JAXBContext) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) URL(java.net.URL) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 4 with MessageReplayObserver

use of org.apache.cxf.jaxws.MessageReplayObserver in project cxf by apache.

the class DispatchTest method testFindOperationWithSource.

@Test
public void testFindOperationWithSource() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), getClass().getResource("/wsdl/hello_world.wsdl"), SERVICE_NAME, null);
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ADDRESS);
    disp.getRequestContext().put("find.dispatch.operation", Boolean.TRUE);
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/sayHiResponse.xml"));
    BindingOperationVerifier bov = new BindingOperationVerifier();
    ((DispatchImpl<?>) disp).getClient().getOutInterceptors().add(bov);
    Document doc = StaxUtils.read(getResourceAsStream("/org/apache/cxf/jaxws/sayHi2.xml"));
    DOMSource source = new DOMSource(doc);
    Source res = disp.invoke(source);
    assertNotNull(res);
    BindingOperationInfo boi = bov.getBindingOperationInfo();
    assertNotNull(boi);
    assertEquals(new QName("http://apache.org/hello_world_soap_http", "sayHi"), boi.getName());
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DispatchImpl(org.apache.cxf.jaxws.DispatchImpl) QName(javax.xml.namespace.QName) Document(org.w3c.dom.Document) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 5 with MessageReplayObserver

use of org.apache.cxf.jaxws.MessageReplayObserver in project cxf by apache.

the class HolderTest method testClient.

@Test
public void testClient() throws Exception {
    EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/soap/http");
    ei.setAddress(ADDRESS);
    Destination d = localTransport.getDestination(ei, bus);
    d.setMessageObserver(new MessageReplayObserver("/org/apache/cxf/jaxws/holder/echoResponse.xml"));
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.getClientFactoryBean().setServiceClass(HolderService.class);
    factory.getClientFactoryBean().setBus(getBus());
    factory.getClientFactoryBean().setAddress(ADDRESS);
    HolderService h = (HolderService) factory.create();
    Holder<String> holder = new Holder<>();
    assertEquals("one", h.echo("one", "two", holder));
    assertEquals("two", holder.value);
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Destination(org.apache.cxf.transport.Destination) Holder(javax.xml.ws.Holder) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) MessageReplayObserver(org.apache.cxf.jaxws.MessageReplayObserver) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Aggregations

AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 MessageReplayObserver (org.apache.cxf.jaxws.MessageReplayObserver)7 Test (org.junit.Test)7 Source (javax.xml.transform.Source)4 DOMSource (javax.xml.transform.dom.DOMSource)4 ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)4 Document (org.w3c.dom.Document)4 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 URL (java.net.URL)2 JAXBContext (javax.xml.bind.JAXBContext)2 SOAPService (org.apache.hello_world_soap_http.SOAPService)2 QName (javax.xml.namespace.QName)1 Holder (javax.xml.ws.Holder)1 AddressingFeature (javax.xml.ws.soap.AddressingFeature)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)1 Destination (org.apache.cxf.transport.Destination)1 SayHi (org.apache.hello_world_soap_http.types.SayHi)1