Search in sources :

Example 6 with BeanInvoker

use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.

the class GreeterTest method testEndpoint.

@Test
public void testEndpoint() throws Exception {
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    Service service = bean.create();
    assertEquals("SOAPService", service.getName().getLocalPart());
    assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
    ServerFactoryBean svr = new ServerFactoryBean();
    svr.setBus(bus);
    svr.setServiceFactory(bean);
    svr.setInvoker(invoker);
    svr.create();
    Node response = invoke("http://localhost:9000/SoapContext/SoapPort", LocalTransportFactory.TRANSPORT_ID, "GreeterMessage.xml");
    assertEquals(1, greeter.getInvocationCount());
    assertNotNull(response);
    addNamespace("h", "http://apache.org/hello_world_soap_http/types");
    assertValid("/s:Envelope/s:Body", response);
    assertValid("//h:sayHiResponse", response);
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) Node(org.w3c.dom.Node) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 7 with BeanInvoker

use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.

the class SoapFaultTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUpBus();
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean();
    URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
    assertNotNull(resource);
    bean.setWsdlURL(resource.toString());
    bean.setBus(bus);
    bean.setServiceClass(GreeterImpl.class);
    GreeterImpl greeter = new GreeterImpl();
    BeanInvoker invoker = new BeanInvoker(greeter);
    bean.setInvoker(invoker);
    service = bean.create();
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setBus(bus);
    svrFactory.setServiceFactory(bean);
    svrFactory.create();
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) URL(java.net.URL) Before(org.junit.Before)

Example 8 with BeanInvoker

use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.

the class EndpointImplTest method testAddWSAFeature.

@Test
public void testAddWSAFeature() throws Exception {
    GreeterImpl greeter = new GreeterImpl();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(greeter));
    serviceFactory.setServiceClass(GreeterImpl.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) {
        endpoint.getFeatures().add(new WSAddressingFeature());
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        assertTrue(serviceFactory.getFeatures().size() == 1);
        assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 9 with BeanInvoker

use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.

the class EndpointImplTest method testWSAnnoWithoutWSDLLocationInSEI.

@Test
public void testWSAnnoWithoutWSDLLocationInSEI() throws Exception {
    HelloImpl hello = new HelloImpl();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(hello));
    serviceFactory.setServiceClass(HelloImpl.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), hello, new JaxWsServerFactoryBean(serviceFactory))) {
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
    }
}
Also used : HelloImpl(org.apache.hello_world_soap_http.HelloImpl) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 10 with BeanInvoker

use of org.apache.cxf.service.invoker.BeanInvoker in project cxf by apache.

the class EndpointImplTest method testJaxWsaFeature.

@Test
public void testJaxWsaFeature() throws Exception {
    HelloWsa greeter = new HelloWsa();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(greeter));
    serviceFactory.setServiceClass(HelloWsa.class);
    try (EndpointImpl endpoint = new EndpointImpl(getBus(), greeter, new JaxWsServerFactoryBean(serviceFactory))) {
        try {
            String address = "http://localhost:8080/test";
            endpoint.publish(address);
        } catch (IllegalArgumentException ex) {
            assertTrue(ex.getCause() instanceof BusException);
            assertEquals("BINDING_INCOMPATIBLE_ADDRESS_EXC", ((BusException) ex.getCause()).getCode());
        }
        assertEquals(1, serviceFactory.getFeatures().size());
        assertTrue(serviceFactory.getFeatures().get(0) instanceof WSAddressingFeature);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) WSAddressingFeature(org.apache.cxf.ws.addressing.WSAddressingFeature) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Aggregations

BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)18 Test (org.junit.Test)12 Server (org.apache.cxf.endpoint.Server)8 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)8 Service (org.apache.cxf.service.Service)8 GreeterImpl (org.apache.hello_world_soap_http.GreeterImpl)6 BusException (org.apache.cxf.BusException)5 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)5 Before (org.junit.Before)5 URL (java.net.URL)4 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)4 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)4 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)3 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)3 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)3 QName (javax.xml.namespace.QName)2 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)2 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)2 WSAddressingFeature (org.apache.cxf.ws.addressing.WSAddressingFeature)2 IOException (java.io.IOException)1