use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class CodeFirstTest method testCXF1510.
@Test
public void testCXF1510() throws Exception {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(NoRootBare.class);
factory.setServiceBean(new NoRootBareImpl());
factory.setAddress("local://localhost/testNoRootBare");
Server server = factory.create();
server.start();
QName serviceName = new QName("http://service.jaxws.cxf.apache.org/", "NoRootBareService");
QName portName = new QName("http://service.jaxws.cxf.apache.org/", "NoRootBarePort");
ServiceImpl service = new ServiceImpl(getBus(), (URL) null, serviceName, null);
service.addPort(portName, "http://schemas.xmlsoap.org/soap/", "local://localhost/testNoRootBare");
NoRootBare proxy = service.getPort(portName, NoRootBare.class);
assertEquals("hello", proxy.echoString(new NoRootRequest("hello")).getMessage());
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class SchemaFirstTest method testEndpoint.
@Test
public void testEndpoint() throws Exception {
JaxWsServerFactoryBean svr = new JaxWsServerFactoryBean();
svr.setBus(bus);
svr.setServiceBean(new EchoFoo());
svr.setAddress("http://localhost:9000/hello");
List<String> schemas = new ArrayList<>();
schemas.add("/org/apache/cxf/jaxws/service/echoFoo.xsd");
svr.setSchemaLocations(schemas);
Server server = svr.create();
Document d = getWSDLDocument(server);
// XmlSchema still isn't preserving all the extra info...
assertValid("//xsd:complexType[@name='foo']/xsd:sequence", d);
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class JaxWsServerFactoryBeanTest method testJaxwsServiceClass.
@Test
public void testJaxwsServiceClass() throws Exception {
JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
factory.setServiceClass(CalculatorPortType.class);
factory.setServiceBean(new CalculatorImpl());
String address = "http://localhost:9001/jaxwstest";
factory.setAddress(address);
Server server = factory.create();
Endpoint endpoint = server.getEndpoint();
ServiceInfo service = endpoint.getEndpointInfo().getService();
assertNotNull(service);
Bus bus = factory.getBus();
Definition def = new ServiceWSDLBuilder(bus, service).build();
WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
def.setExtensionRegistry(bus.getExtension(WSDLManager.class).getExtensionRegistry());
Document doc = wsdlWriter.getDocument(def);
Map<String, String> ns = new HashMap<>();
ns.put("wsdl", "http://schemas.xmlsoap.org/wsdl/");
ns.put("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
XPathUtils xpather = new XPathUtils(ns);
xpather.isExist("/wsdl:definitions/wsdl:binding/soap:binding", doc, XPathConstants.NODE);
xpather.isExist("/wsdl:definitions/wsdl:binding/wsdl:operation[@name='add']/soap:operation", doc, XPathConstants.NODE);
xpather.isExist("/wsdl:definitions/wsdl:service/wsdl:port[@name='add']/soap:address[@location='" + address + "']", doc, XPathConstants.NODE);
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class CodeFirstTest method testNamespacedWebParamsWrapped.
@Test
public void testNamespacedWebParamsWrapped() throws Exception {
JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
sf.setAddress("local://localhost/test");
sf.setServiceBean(new FooServiceImpl());
sf.getServiceFactory().setWrapped(true);
Server server = sf.create();
Document doc = getWSDLDocument(server);
// DOMUtils.writeXml(doc, System.out);
assertValid("//xsd:schema[@targetNamespace='http://namespace3']", doc);
assertValid("//xsd:schema[@targetNamespace='http://namespace5']", doc);
}
use of org.apache.cxf.endpoint.Server in project cxf by apache.
the class MDBActivationWork method activate.
/**
* @param invoker
* @param classLoader
*/
private void activate(MDBInvoker invoker, ClassLoader classLoader) {
Class<?> serviceClass = null;
if (spec.getServiceInterfaceClass() != null) {
try {
serviceClass = Class.forName(spec.getServiceInterfaceClass(), false, classLoader);
} catch (ClassNotFoundException e) {
LOG.severe("Failed to activate service endpoint " + spec.getDisplayName() + " due to unable to endpoint listener.");
return;
}
}
Bus bus = null;
if (spec.getBusConfigLocation() != null) {
URL url = classLoader.getResource(spec.getBusConfigLocation());
if (url == null) {
LOG.warning("Unable to get bus configuration from " + spec.getBusConfigLocation());
} else {
bus = new SpringBusFactory().createBus(url);
}
}
if (bus == null) {
bus = BusFactory.getDefaultBus();
}
Method method = null;
try {
Class<?> clazz = org.apache.cxf.jca.inbound.DispatchMDBMessageListener.class;
method = clazz.getMethod(MESSAGE_LISTENER_METHOD, new Class[] { String.class });
} catch (Exception ex) {
LOG.severe("Failed to get method " + MESSAGE_LISTENER_METHOD + " from class DispatchMDBMessageListener.");
}
Server server = createServer(bus, serviceClass, invoker);
if (server == null) {
LOG.severe("Failed to create CXF facade service endpoint.");
return;
}
EndpointInfo ei = server.getEndpoint().getEndpointInfo();
ei.setProperty(MESSAGE_ENDPOINT_FACTORY, endpointFactory);
ei.setProperty(MDB_TRANSACTED_METHOD, method);
server.start();
// save the server for clean up later
endpoints.put(spec.getDisplayName(), new InboundEndpoint(server, invoker));
}
Aggregations