Java Code Examples for org.apache.cxf.frontend.ServerFactoryBean#setServiceFactory()
The following examples show how to use
org.apache.cxf.frontend.ServerFactoryBean#setServiceFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientServiceConfigTest.java From cxf with Apache License 2.0 | 6 votes |
@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"); }
Example 2
Source File: SoapFaultTest.java From cxf with Apache License 2.0 | 6 votes |
@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(); }
Example 3
Source File: CodeFirstTest.java From cxf with Apache License 2.0 | 6 votes |
private Definition createService(boolean wrapped) throws Exception { ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(); Bus bus = getBus(); bean.setBus(bus); bean.setServiceClass(Hello.class); bean.setWrapped(wrapped); Service service = bean.create(); InterfaceInfo i = service.getServiceInfos().get(0).getInterface(); assertEquals(5, i.getOperations().size()); ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceFactory(bean); svrFactory.setAddress(address); svrFactory.create(); Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings(); assertEquals(1, bindings.size()); ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0)); return wsdlBuilder.build(); }
Example 4
Source File: CodeFirstWSDLTest.java From cxf with Apache License 2.0 | 5 votes |
private Definition createService(Class<?> clazz) throws Exception { JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz); ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info); Bus bus = getBus(); bean.setBus(bus); Service service = bean.create(); InterfaceInfo i = service.getServiceInfos().get(0).getInterface(); assertEquals(5, i.getOperations().size()); ServerFactoryBean svrFactory = new ServerFactoryBean(); svrFactory.setBus(bus); svrFactory.setServiceFactory(bean); svrFactory.setServiceBean(clazz.newInstance()); svrFactory.setAddress(address); svrFactory.create(); Collection<BindingInfo> bindings = service.getServiceInfos().get(0).getBindings(); assertEquals(1, bindings.size()); ServiceWSDLBuilder wsdlBuilder = new ServiceWSDLBuilder(bus, service.getServiceInfos().get(0)); return wsdlBuilder.build(); }
Example 5
Source File: GreeterTest.java From cxf with Apache License 2.0 | 5 votes |
@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); }
Example 6
Source File: HeaderTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testInvocation() throws Exception { JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(); Bus bus = getBus(); bean.setBus(bus); bean.setServiceClass(TestHeaderImpl.class); Service service = bean.create(); OperationInfo op = service.getServiceInfos().get(0).getInterface().getOperation( new QName(service.getName().getNamespaceURI(), "testHeader5")); assertNotNull(op); List<MessagePartInfo> parts = op.getInput().getMessageParts(); assertEquals(1, parts.size()); MessagePartInfo part = parts.get(0); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5.class, part.getTypeClass()); parts = op.getOutput().getMessageParts(); assertEquals(2, parts.size()); part = parts.get(1); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5ResponseBody.class, part.getTypeClass()); part = parts.get(0); assertNotNull(part.getTypeClass()); assertEquals(TestHeader5.class, part.getTypeClass()); // part = parts.get(1); // assertNotNull(part.getTypeClass()); ServerFactoryBean svr = new ServerFactoryBean(); svr.setBus(bus); svr.setServiceFactory(bean); svr.setServiceBean(new TestHeaderImpl()); svr.setAddress("http://localhost:9104/SoapHeaderContext/SoapHeaderPort"); svr.setBindingConfig(new JaxWsSoapBindingConfiguration(bean)); svr.create(); Node response = invoke("http://localhost:9104/SoapHeaderContext/SoapHeaderPort", LocalTransportFactory.TRANSPORT_ID, "testHeader5.xml"); assertNotNull(response); assertNoFault(response); addNamespace("t", "http://apache.org/header_test/types"); assertValid("//s:Header/t:testHeader5", response); }
Example 7
Source File: ReflectionServiceFactoryTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testServerFactoryBean() throws Exception { Service service = createService(true); assertEquals("test", service.get("test")); ServerFactoryBean svrBean = new ServerFactoryBean(); svrBean.setAddress("http://localhost/Hello"); svrBean.setServiceFactory(serviceFactory); svrBean.setServiceBean(new HelloServiceImpl()); svrBean.setBus(getBus()); Map<String, Object> props = new HashMap<>(); props.put("test", "test"); serviceFactory.setProperties(props); svrBean.setProperties(props); Server server = svrBean.create(); assertNotNull(server); Map<QName, Endpoint> eps = service.getEndpoints(); assertEquals(1, eps.size()); Endpoint ep = eps.values().iterator().next(); EndpointInfo endpointInfo = ep.getEndpointInfo(); assertEquals("test", ep.get("test")); BindingInfo b = endpointInfo.getService().getBindings().iterator().next(); assertTrue(b instanceof SoapBindingInfo); SoapBindingInfo sb = (SoapBindingInfo) b; assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart()); assertEquals("document", sb.getStyle()); assertEquals(4, b.getOperations().size()); BindingOperationInfo bop = b.getOperations().iterator().next(); SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class); assertNotNull(sop); assertEquals("", sop.getAction()); assertEquals("document", sop.getStyle()); }