Search in sources :

Example 1 with BeanInvoker

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

the class ClientServiceConfigTest method before.

@Before
public void before() throws Exception {
    super.setUp();
    ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean();
    factory.setInvoker(new BeanInvoker(new EchoImpl()));
    factory.setDataBinding(new AegisDatabinding());
    ServerFactoryBean svrFac = new ServerFactoryBean();
    svrFac.setAddress("local://Echo");
    svrFac.setServiceFactory(factory);
    svrFac.setServiceClass(Echo.class);
    svrFac.setBus(getBus());
    svrFac.create();
    Endpoint endpoint = Endpoint.create(new EchoImpl());
    impl = (EndpointImpl) endpoint;
    impl.setDataBinding(new AegisDatabinding());
    endpoint.publish("local://JaxWsEcho");
}
Also used : Endpoint(javax.xml.ws.Endpoint) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) Before(org.junit.Before)

Example 2 with BeanInvoker

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

the class ExceptionTest method testJaxwsServerSimpleClient.

@Test(expected = HelloException.class)
public void testJaxwsServerSimpleClient() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs1");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs1");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);
    clientInterface.sayHiWithException();
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Service(org.apache.cxf.service.Service) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 3 with BeanInvoker

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

the class ExceptionTest method testJaxws.

@Test(expected = HelloException.class)
public void testJaxws() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    setupAegis(sfbean);
    sfbean.setAddress("local://ExceptionService4");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
    JaxWsProxyFactoryBean proxyFac = new JaxWsProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionService4");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);
    clientInterface.sayHiWithException();
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Service(org.apache.cxf.service.Service) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 4 with BeanInvoker

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

the class EndpointImplTest method testSOAPBindingOnMethodWithRPC.

@Test
public void testSOAPBindingOnMethodWithRPC() {
    HelloWrongAnnotation hello = new HelloWrongAnnotation();
    JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
    serviceFactory.setBus(getBus());
    serviceFactory.setInvoker(new BeanInvoker(hello));
    serviceFactory.setServiceClass(HelloWrongAnnotation.class);
    try {
        new EndpointImpl(getBus(), hello, new JaxWsServerFactoryBean(serviceFactory)).close();
    } catch (Exception e) {
        String expeced = "Method [sayHi] processing error: SOAPBinding can not on method with RPC style";
        assertEquals(expeced, e.getMessage());
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) HelloWrongAnnotation(org.apache.hello_world_soap_http.HelloWrongAnnotation) BusException(org.apache.cxf.BusException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with BeanInvoker

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

the class EndpointImplTest method testEndpointServiceConstructor.

@Test
public void testEndpointServiceConstructor() 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))) {
        WebServiceContext ctx = greeter.getContext();
        assertNull(ctx);
        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());
        }
        ctx = greeter.getContext();
        assertNotNull(ctx);
    }
}
Also used : JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) WebServiceContext(javax.xml.ws.WebServiceContext) 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