Search in sources :

Example 36 with Server

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());
}
Also used : Server(org.apache.cxf.endpoint.Server) QName(javax.xml.namespace.QName) ArrayServiceImpl(org.apache.cxf.jaxws.service.ArrayServiceImpl) FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) Test(org.junit.Test)

Example 37 with Server

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);
}
Also used : Server(org.apache.cxf.endpoint.Server) ArrayList(java.util.ArrayList) EchoFoo(org.apache.cxf.jaxws.service.EchoFoo) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 38 with Server

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);
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) Definition(javax.wsdl.Definition) WSDLWriter(javax.wsdl.xml.WSDLWriter) Document(org.w3c.dom.Document) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) XPathUtils(org.apache.cxf.helpers.XPathUtils) CalculatorImpl(org.apache.cxf.calculator.CalculatorImpl) Test(org.junit.Test)

Example 39 with Server

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);
}
Also used : FooServiceImpl(org.apache.cxf.jaxws.service.FooServiceImpl) Server(org.apache.cxf.endpoint.Server) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 40 with Server

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));
}
Also used : Bus(org.apache.cxf.Bus) Server(org.apache.cxf.endpoint.Server) Method(java.lang.reflect.Method) URL(java.net.URL) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory)

Aggregations

Server (org.apache.cxf.endpoint.Server)199 Test (org.junit.Test)119 ReferenceParametersType (org.apache.cxf.ws.addressing.ReferenceParametersType)54 ResourceManager (org.apache.cxf.ws.transfer.manager.ResourceManager)52 MemoryResourceManager (org.apache.cxf.ws.transfer.manager.MemoryResourceManager)50 Resource (org.apache.cxf.ws.transfer.resource.Resource)50 ExpressionType (org.apache.cxf.ws.transfer.dialect.fragment.ExpressionType)47 ValueType (org.apache.cxf.ws.transfer.dialect.fragment.ValueType)44 Element (org.w3c.dom.Element)44 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)33 Put (org.apache.cxf.ws.transfer.Put)33 Fragment (org.apache.cxf.ws.transfer.dialect.fragment.Fragment)32 Service (org.apache.cxf.service.Service)27 Bus (org.apache.cxf.Bus)25 PutResponse (org.apache.cxf.ws.transfer.PutResponse)25 Endpoint (org.apache.cxf.endpoint.Endpoint)21 ArrayList (java.util.ArrayList)18 QName (javax.xml.namespace.QName)18 ServerRegistry (org.apache.cxf.endpoint.ServerRegistry)18 Document (org.w3c.dom.Document)18