Search in sources :

Example 41 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class EndpointImpl method publish.

public void publish(javax.xml.ws.spi.http.HttpContext context) {
    ServerFactoryBean sf = getServerFactory();
    if (sf.getDestinationFactory() == null) {
        sf.setDestinationFactory(new JAXWSHttpSpiTransportFactory(context));
    }
    publish(context.getPath());
}
Also used : JAXWSHttpSpiTransportFactory(org.apache.cxf.transport.http_jaxws_spi.JAXWSHttpSpiTransportFactory) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean)

Example 42 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class HeaderTest method testInvocation.

@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);
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) Bus(org.apache.cxf.Bus) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) QName(javax.xml.namespace.QName) Node(org.w3c.dom.Node) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsSoapBindingConfiguration(org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) TestHeaderImpl(org.apache.header_test.TestHeaderImpl) Test(org.junit.Test)

Example 43 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class JaxWsServerFactoryBeanTest method testSimpleServiceClass.

@Test
public void testSimpleServiceClass() throws Exception {
    ServerFactoryBean factory = new ServerFactoryBean();
    factory.setServiceClass(Hello.class);
    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) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) 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) Test(org.junit.Test)

Example 44 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class AnnotationInterceptorTest method setUp.

@Before
public void setUp() {
    fb = new ServerFactoryBean();
    fb.setAddress("local://localhost");
    fb.setBus(getBus());
    jfb = new JaxWsServerFactoryBean();
    jfb.setAddress("local://localhost");
    jfb.setBus(getBus());
}
Also used : JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Before(org.junit.Before)

Example 45 with ServerFactoryBean

use of org.apache.cxf.frontend.ServerFactoryBean in project cxf by apache.

the class Server method startServer.

public static void startServer() throws Exception {
    HelloWorldImpl helloworldImpl = new HelloWorldImpl();
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    svrFactory.setServiceClass(HelloWorld.class);
    svrFactory.setAddress("http://localhost:9000/Hello");
    svrFactory.setServiceBean(helloworldImpl);
    svrFactory.getServiceFactory().setDataBinding(new AegisDatabinding());
    svrFactory.create();
}
Also used : ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding)

Aggregations

ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)48 Test (org.junit.Test)16 Server (org.apache.cxf.endpoint.Server)9 Before (org.junit.Before)9 BeforeClass (org.junit.BeforeClass)9 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)8 AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)6 QName (javax.xml.namespace.QName)5 JaxWsServiceFactoryBean (org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)5 Service (org.apache.cxf.service.Service)5 Node (org.w3c.dom.Node)5 Bus (org.apache.cxf.Bus)4 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)4 HashMap (java.util.HashMap)3 ServerImpl (org.apache.cxf.endpoint.ServerImpl)3 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)3 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)3 AbstractCXFTest (org.apache.cxf.test.AbstractCXFTest)3 ServiceWSDLBuilder (org.apache.cxf.wsdl11.ServiceWSDLBuilder)3 URL (java.net.URL)2