Search in sources :

Example 36 with ServerFactoryBean

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

the class RountripTest method testOneWay.

@Test
public void testOneWay() throws Exception {
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello2");
    svrBean.setTransportId("http://schemas.xmlsoap.org/soap/http");
    svrBean.setServiceBean(new GreeterImplDoc());
    svrBean.setServiceClass(Greeter.class);
    svrBean.setEndpointName(new QName("http://apache.org/hello_world_doc_lit", "SoapPort"));
    svrBean.setServiceName(new QName("http://apache.org/hello_world_doc_lit", "SOAPService"));
    svrBean.setWsdlLocation("testutils/hello_world_doc_lit.wsdl");
    svrBean.setBus(getBus());
    svrBean.create();
}
Also used : QName(javax.xml.namespace.QName) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) GreeterImplDoc(org.apache.hello_world_doc_lit.GreeterImplDoc) Test(org.junit.Test)

Example 37 with ServerFactoryBean

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

the class StaxDatabindingTest method testCallback.

@Test
public void testCallback() throws Exception {
    String address = "local://foo";
    ServerFactoryBean sf = new ServerFactoryBean();
    sf.setServiceBean(new CallbackService());
    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    sf.setAddress(address);
    sf.setDataBinding(new StaxDataBinding());
    sf.getFeatures().add(new StaxDataBindingFeature());
    sf.setBus(getBus());
    sf.create();
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "req.xml");
    assertValid("//bleh", res);
}
Also used : StaxDataBindingFeature(org.apache.cxf.databinding.stax.StaxDataBindingFeature) Node(org.w3c.dom.Node) StaxDataBinding(org.apache.cxf.databinding.stax.StaxDataBinding) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

Example 38 with ServerFactoryBean

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

the class StaxDatabindingTest method testCopy.

@Test
public void testCopy() throws Exception {
    String address = "local://foo";
    ServerFactoryBean sf = new ServerFactoryBean();
    sf.setServiceBean(new CopyService());
    sf.setBus(getBus());
    sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
    sf.setAddress(address);
    sf.setDataBinding(new StaxDataBinding());
    sf.getFeatures().add(new StaxDataBindingFeature());
    sf.create().start();
    Node res = invoke(address, LocalTransportFactory.TRANSPORT_ID, "req.xml");
    // DOMUtils.writeXml(res, System.out);
    addNamespace("a", "http://stax.service.cxf.apache.org/");
    assertValid("//a:bleh", res);
}
Also used : StaxDataBindingFeature(org.apache.cxf.databinding.stax.StaxDataBindingFeature) Node(org.w3c.dom.Node) StaxDataBinding(org.apache.cxf.databinding.stax.StaxDataBinding) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

Example 39 with ServerFactoryBean

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

the class GenericAegisTest method testGenerateJavascript.

// the claim is that code generation makes this go boom.
@Test
public void testGenerateJavascript() throws Exception {
    // Create our service implementation
    GenericGenericClass<String> impl = new GenericGenericClass<String>();
    // Create our Server
    ServerFactoryBean svrFactory = new ServerFactoryBean();
    // we sure can't get a .class for the interface, can we?
    svrFactory.setServiceClass(impl.getClass());
    svrFactory.setAddress("http://localhost:" + PORT + "/aegisgeneric");
    svrFactory.setServiceBean(impl);
    Server server = svrFactory.create();
    ServiceInfo serviceInfo = ((EndpointImpl) server.getEndpoint()).getEndpointInfo().getService();
    Collection<SchemaInfo> schemata = serviceInfo.getSchemas();
    BasicNameManager nameManager = BasicNameManager.newNameManager(serviceInfo);
    NamespacePrefixAccumulator prefixManager = new NamespacePrefixAccumulator(serviceInfo.getXmlSchemaCollection());
    for (SchemaInfo schema : schemata) {
        SchemaJavascriptBuilder builder = new SchemaJavascriptBuilder(serviceInfo.getXmlSchemaCollection(), prefixManager, nameManager);
        String allThatJavascript = builder.generateCodeForSchema(schema.getSchema());
        assertNotNull(allThatJavascript);
    }
    ServiceJavascriptBuilder serviceBuilder = new ServiceJavascriptBuilder(serviceInfo, null, prefixManager, nameManager);
    serviceBuilder.walk();
    String serviceJavascript = serviceBuilder.getCode();
    assertNotNull(serviceJavascript);
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) ServiceJavascriptBuilder(org.apache.cxf.javascript.service.ServiceJavascriptBuilder) Server(org.apache.cxf.endpoint.Server) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) GenericGenericClass(org.apache.cxf.javascript.fortest.GenericGenericClass) SchemaInfo(org.apache.cxf.service.model.SchemaInfo) SchemaJavascriptBuilder(org.apache.cxf.javascript.types.SchemaJavascriptBuilder) Test(org.junit.Test)

Example 40 with ServerFactoryBean

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

the class CodeFirstWSDLTest method createService.

private Definition createService(Class<?> clazz) throws Exception {
    JaxWsImplementorInfo info = new JaxWsImplementorInfo(clazz);
    ReflectionServiceFactoryBean bean = new JaxWsServiceFactoryBean(info);
    Bus bus = getBus();
    bean.setBus(bus);
    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.setServiceBean(clazz.newInstance());
    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();
}
Also used : Bus(org.apache.cxf.Bus) JaxWsImplementorInfo(org.apache.cxf.jaxws.support.JaxWsImplementorInfo) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean) ServiceWSDLBuilder(org.apache.cxf.wsdl11.ServiceWSDLBuilder)

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