Search in sources :

Example 1 with ServiceImpl

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

the class DispatchTest method testInterceptorsConfiguration.

@Test
public // CXF-2822
void testInterceptorsConfiguration() throws Exception {
    String cfgFile = "org/apache/cxf/jaxws/dispatch/bus-dispatch.xml";
    Bus bus = new SpringBusFactory().createBus(cfgFile, true);
    ServiceImpl service = new ServiceImpl(bus, getClass().getResource("/wsdl/hello_world.wsdl"), SERVICE_NAME, null);
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    List<Interceptor<? extends Message>> interceptors = ((DispatchImpl<?>) disp).getClient().getInInterceptors();
    boolean exists = false;
    for (Interceptor<? extends Message> interceptor : interceptors) {
        if (interceptor instanceof LoggingInInterceptor) {
            exists = true;
        }
    }
    assertTrue("The LoggingInInterceptor is not configured to dispatch client", exists);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) Message(org.apache.cxf.message.Message) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) AbstractSoapInterceptor(org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 2 with ServiceImpl

use of org.apache.cxf.jaxws.ServiceImpl 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 ServiceImpl

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

the class DispatchTest method testSOAPPBinding.

@Test
public void testSOAPPBinding() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), null, SERVICE_NAME, null);
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "local://foobar");
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    assertTrue(disp.getBinding() instanceof SOAPBinding);
}
Also used : ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) SOAPBinding(javax.xml.ws.soap.SOAPBinding) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 4 with ServiceImpl

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

the class DispatchTest method testHTTPBinding.

@Test
public void testHTTPBinding() throws Exception {
    ServiceImpl service = new ServiceImpl(getBus(), null, SERVICE_NAME, null);
    service.addPort(PORT_NAME, HTTPBinding.HTTP_BINDING, "local://foobar");
    Dispatch<Source> disp = service.createDispatch(PORT_NAME, Source.class, Service.Mode.MESSAGE);
    assertTrue(disp.getBinding() instanceof HTTPBinding);
}
Also used : ServiceImpl(org.apache.cxf.jaxws.ServiceImpl) DOMSource(javax.xml.transform.dom.DOMSource) Source(javax.xml.transform.Source) HTTPBinding(javax.xml.ws.http.HTTPBinding) Test(org.junit.Test) AbstractJaxWsTest(org.apache.cxf.jaxws.AbstractJaxWsTest)

Example 5 with ServiceImpl

use of org.apache.cxf.jaxws.ServiceImpl 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)

Aggregations

ServiceImpl (org.apache.cxf.jaxws.ServiceImpl)14 Test (org.junit.Test)11 Source (javax.xml.transform.Source)7 DOMSource (javax.xml.transform.dom.DOMSource)7 AbstractJaxWsTest (org.apache.cxf.jaxws.AbstractJaxWsTest)7 W3CEndpointReference (javax.xml.ws.wsaddressing.W3CEndpointReference)4 Number (org.apache.cxf.factory_pattern.Number)4 NumberFactory (org.apache.cxf.factory_pattern.NumberFactory)4 NumberFactoryService (org.apache.cxf.factory_pattern.NumberFactoryService)4 NumberService (org.apache.cxf.factory_pattern.NumberService)4 MessageReplayObserver (org.apache.cxf.jaxws.MessageReplayObserver)4 Document (org.w3c.dom.Document)4 DispatchImpl (org.apache.cxf.jaxws.DispatchImpl)3 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)3 Service (javax.xml.ws.Service)2 Bus (org.apache.cxf.Bus)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 QName (javax.xml.namespace.QName)1 WebServiceException (javax.xml.ws.WebServiceException)1