use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.
the class CodeFirstTest method createService.
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();
}
use of org.apache.cxf.frontend.ServerFactoryBean 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);
}
use of org.apache.cxf.frontend.ServerFactoryBean 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();
}
use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.
the class MDBActivationWork method createServer.
private Server createServer(Bus bus, Class<?> serviceClass, MDBInvoker invoker) {
// create server bean factory
ServerFactoryBean factory = null;
if (serviceClass != null && EndpointUtils.hasWebServiceAnnotation(serviceClass)) {
factory = new JaxWsServerFactoryBean();
} else {
factory = new ServerFactoryBean();
}
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Creating a server using " + factory.getClass().getName());
}
if (serviceClass != null) {
factory.setServiceClass(serviceClass);
}
if (spec.getWsdlLocation() != null) {
factory.setWsdlLocation(spec.getWsdlLocation());
}
if (spec.getAddress() != null) {
factory.setAddress(spec.getAddress());
}
factory.setBus(bus);
if (spec.getEndpointName() != null) {
factory.setEndpointName(QName.valueOf(spec.getEndpointName()));
}
if (spec.getSchemaLocations() != null) {
factory.setSchemaLocations(getListOfString(spec.getSchemaLocations()));
}
if (spec.getServiceName() != null) {
factory.setServiceName(QName.valueOf(spec.getServiceName()));
}
factory.setInvoker(invoker);
// Don't start the server yet
factory.setStart(false);
Server retval = null;
if (factory instanceof JaxWsServerFactoryBean) {
retval = createServerFromJaxwsEndpoint((JaxWsServerFactoryBean) factory);
} else {
retval = factory.create();
}
return retval;
}
use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.
the class ReflectionServiceFactoryTest method testServerFactoryBean.
@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());
}
Aggregations