use of org.apache.cxf.endpoint.ServerImpl in project cxf by apache.
the class ProviderServiceFactoryTest method testSOAPBindingFromCode.
@Test
public void testSOAPBindingFromCode() throws Exception {
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean();
bean.setServiceClass(SOAPSourcePayloadProvider.class);
bean.setBus(getBus());
bean.setInvoker(new JAXWSMethodInvoker(new SOAPSourcePayloadProvider()));
Service service = bean.create();
assertEquals("SOAPSourcePayloadProviderService", service.getName().getLocalPart());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
assertNotNull(intf);
assertEquals(1, intf.getOperations().size());
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(getBus());
svrFactory.setServiceFactory(bean);
String address = "local://localhost:9000/test";
svrFactory.setAddress(address);
ServerImpl server = (ServerImpl) svrFactory.create();
// See if our endpoint was created correctly
assertEquals(1, service.getServiceInfos().get(0).getEndpoints().size());
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof SoapBinding);
SoapBindingInfo sb = (SoapBindingInfo) endpoint.getEndpointInfo().getBinding();
assertEquals("document", sb.getStyle());
assertEquals(false, bean.isWrapped());
assertEquals(1, sb.getOperations().size());
Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "/org/apache/cxf/jaxws/sayHi.xml");
addNamespace("j", "http://service.jaxws.cxf.apache.org/");
assertValid("/s:Envelope/s:Body/j:sayHi", res);
}
use of org.apache.cxf.endpoint.ServerImpl in project cxf by apache.
the class EndpointImpl method getServer.
public synchronized ServerImpl getServer(String addr) {
if (server == null) {
checkProperties();
ClassLoaderHolder loader = null;
try {
if (bus != null) {
ClassLoader newLoader = bus.getExtension(ClassLoader.class);
if (newLoader != null) {
loader = ClassLoaderUtils.setThreadContextClassloader(newLoader);
}
}
// Initialize the endpointName so we can do configureObject
QName origEpn = endpointName;
if (endpointName == null) {
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(getImplementorClass());
endpointName = implInfo.getEndpointName();
}
if (serviceFactory != null) {
serverFactory.setServiceFactory(serviceFactory);
}
/*if (serviceName != null) {
serverFactory.getServiceFactory().setServiceName(serviceName);
}*/
configureObject(this);
endpointName = origEpn;
// Set up the server factory
serverFactory.setAddress(addr);
serverFactory.setStart(false);
serverFactory.setEndpointName(endpointName);
serverFactory.setServiceBean(implementor);
serverFactory.setBus(bus);
serverFactory.setFeatures(getFeatures());
serverFactory.setInvoker(invoker);
serverFactory.setSchemaLocations(schemaLocations);
if (serverFactory.getProperties() != null) {
serverFactory.getProperties().putAll(properties);
} else {
serverFactory.setProperties(properties);
}
// have supplied their own.
if (getWsdlLocation() != null) {
serverFactory.setWsdlURL(getWsdlLocation());
}
if (bindingUri != null) {
serverFactory.setBindingId(bindingUri);
}
if (serviceName != null) {
serverFactory.getServiceFactory().setServiceName(serviceName);
}
if (implementorClass != null) {
serverFactory.setServiceClass(implementorClass);
}
if (executor != null) {
serverFactory.getServiceFactory().setExecutor(executor);
}
if (!handlers.isEmpty()) {
serverFactory.addHandlers(handlers);
}
configureObject(serverFactory);
server = serverFactory.create();
org.apache.cxf.endpoint.Endpoint endpoint = getEndpoint();
if (in != null) {
endpoint.getInInterceptors().addAll(in);
}
if (out != null) {
endpoint.getOutInterceptors().addAll(out);
}
if (inFault != null) {
endpoint.getInFaultInterceptors().addAll(inFault);
}
if (outFault != null) {
endpoint.getOutFaultInterceptors().addAll(outFault);
}
if (properties != null) {
endpoint.putAll(properties);
}
configureObject(endpoint.getService());
configureObject(endpoint);
this.service = endpoint.getService();
if (getWsdlLocation() == null) {
// hold onto the wsdl location so cache won't clear till we go away
setWsdlLocation(serverFactory.getWsdlURL());
}
if (serviceName == null) {
setServiceName(serverFactory.getServiceFactory().getServiceQName());
}
if (endpointName == null) {
endpointName = endpoint.getEndpointInfo().getName();
}
} finally {
if (loader != null) {
loader.reset();
}
}
}
return (ServerImpl) server;
}
use of org.apache.cxf.endpoint.ServerImpl in project cxf by apache.
the class ServerFactoryTest method testSetDF.
@Test
public void testSetDF() throws Exception {
ServerFactoryBean svrBean = new ServerFactoryBean();
svrBean.setAddress("http://localhost/Hello");
svrBean.setServiceClass(HelloService.class);
svrBean.setServiceBean(new HelloServiceImpl());
svrBean.setBus(getBus());
svrBean.setDestinationFactory(new CustomDestinationFactory(getBus()));
ServerImpl server = (ServerImpl) svrBean.create();
assertTrue(server.getDestination() instanceof CustomDestination);
}
use of org.apache.cxf.endpoint.ServerImpl in project cxf by apache.
the class ServerFactoryTest method testCXF1758.
@Test
public void testCXF1758() throws Exception {
ServerFactoryBean svrBean = new ServerFactoryBean();
svrBean.setAddress("http://localhost/Generics");
svrBean.setServiceBean(new TestServiceImpl<String>() {
});
svrBean.setBus(getBus());
ServerImpl server = (ServerImpl) svrBean.create();
// XMLUtils.printDOM(getWSDLDocument(server));
assertValid("//xsd:schema/xsd:complexType[@name='open']/xsd:sequence/" + "xsd:element[@type='xsd:string']", getWSDLDocument(server));
}
use of org.apache.cxf.endpoint.ServerImpl in project cxf by apache.
the class ProviderServiceFactoryTest method testFromWSDL.
@Test
public void testFromWSDL() throws Exception {
URL resource = getClass().getResource("/wsdl/hello_world.wsdl");
assertNotNull(resource);
JaxWsImplementorInfo implInfo = new JaxWsImplementorInfo(HWSoapMessageProvider.class);
JaxWsServiceFactoryBean bean = new JaxWsServiceFactoryBean(implInfo);
bean.setWsdlURL(resource.toString());
Bus bus = getBus();
bean.setBus(bus);
bean.setServiceClass(HWSoapMessageProvider.class);
Service service = bean.create();
assertTrue(service.getInvoker() instanceof JAXWSMethodInvoker);
assertEquals("SOAPService", service.getName().getLocalPart());
assertEquals("http://apache.org/hello_world_soap_http", service.getName().getNamespaceURI());
InterfaceInfo intf = service.getServiceInfos().get(0).getInterface();
assertNotNull(intf);
JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
svrFactory.setBus(bus);
svrFactory.setServiceFactory(bean);
svrFactory.setStart(false);
ServerImpl server = (ServerImpl) svrFactory.create();
assertTrue(server.getEndpoint().getService().getInvoker() instanceof JAXWSMethodInvoker);
Endpoint endpoint = server.getEndpoint();
Binding binding = endpoint.getBinding();
assertTrue(binding instanceof SoapBinding);
}
Aggregations