Package org.apache.cxf.jaxws

Examples of org.apache.cxf.jaxws.JaxWsServerFactoryBean


public class BookServer extends AbstractBusTestServerBase {
    public static final String PORT = allocatePort(BookServer.class);
    protected void run() {
        //book service in unwrapped style
        BookServiceImpl serviceObj = new BookServiceImpl();
        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setServiceClass(BookService.class);
        // Use the HTTP Binding which understands the Java Rest Annotations
        sf.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sf.setAddress("http://localhost:" + PORT + "/xml/");
        sf.getServiceFactory().setInvoker(new BeanInvoker(serviceObj));

        // Turn the "wrapped" style off. This means that CXF won't generate
        // wrapper XML elements and we'll have prettier XML text. This
        // means that we need to stick to one request and one response
        // parameter though.
        sf.getServiceFactory().setWrapped(false);

        sf.create();
       
        //book service in wrapped style
        BookServiceWrappedImpl serviceWrappedObj = new BookServiceWrappedImpl();
        JaxWsServerFactoryBean sfWrapped = new JaxWsServerFactoryBean();
        sfWrapped.setServiceClass(BookServiceWrapped.class);
        // Use the HTTP Binding which understands the Java Rest Annotations
        sfWrapped.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sfWrapped.setAddress("http://localhost:" + PORT + "/xmlwrapped");
        sfWrapped.getServiceFactory().setInvoker(new BeanInvoker(serviceWrappedObj));
        sfWrapped.create();
       
       
        JaxWsServerFactoryBean sfJson = new JaxWsServerFactoryBean();
        sfJson.setServiceClass(BookService.class);
        // Use the HTTP Binding which understands the Java Rest Annotations
        sfJson.setBindingId(HttpBindingFactory.HTTP_BINDING_ID);
        sfJson.setAddress("http://localhost:" + PORT + "/json");
        sfJson.getServiceFactory().setInvoker(new BeanInvoker(serviceObj));

        // Turn the "wrapped" style off. This means that CXF won't generate
        // wrapper JSON elements and we'll have prettier JSON text. This
        // means that we need to stick to one request and one response
        // parameter though.
        sfJson.getServiceFactory().setWrapped(false);

        // Tell CXF to use a different Content-Type for the JSON endpoint
        // This should probably be application/json, but text/plain allows
        // us to view easily in a web browser.
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("Content-Type", "text/plain");

        // Set up the JSON StAX implementation
        Map<String, String> nstojns = new HashMap<String, String>();
        nstojns.put("http://book.acme.com", "acme");

        MappedXMLInputFactory xif = new MappedXMLInputFactory(nstojns);
        properties.put(XMLInputFactory.class.getName(), xif);

        MappedXMLOutputFactory xof = new MappedXMLOutputFactory(nstojns);
        properties.put(XMLOutputFactory.class.getName(), xof);

        sfJson.setProperties(properties);

        sfJson.create();
    }
View Full Code Here


        TestUtilities.recoverKeepAliveSystemProperty();
    }

    @Test
    public void testMtomRequest() throws Exception {
        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setServiceBean(new EchoService());
        sf.setBus(getBus());
        String address = "http://localhost:" + PORT + "/EchoService";
        sf.setAddress(address);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Message.MTOM_ENABLED, "true");
        sf.setProperties(props);
        sf.create();

        EndpointInfo ei = new EndpointInfo(null, HTTP_ID);
        ei.setAddress(address);

        ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class);
View Full Code Here

        assertEquals(37448, out.size());
    }

    @Test
    public void testURLBasedAttachment() throws Exception {
        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
        sf.setServiceBean(new EchoService());
        sf.setBus(getBus());
        String address = "http://localhost:" + PORT + "/EchoService";
        sf.setAddress(address);
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Message.MTOM_ENABLED, "true");
        sf.setProperties(props);
        Server server = sf.create();
        server.getEndpoint().getService().getDataBinding().setMtomThreshold(0);

        servStatic(getClass().getResource("mtom-policy.xml"),
                   "http://localhost:" + PORT + "/policy.xsd");
View Full Code Here

            imi.setEnabled(true);
            imi.init();

           
            Greeter greeter1 = new GreeterImpl();
            JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
            svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello");
            svrFactory.setServiceBean(greeter1);
            svrFactory.getProperties(true).put("managed.endpoint.name", "greeter1");
            svrFactory.create();

            Greeter greeter2 = new GreeterImpl();
            svrFactory = new JaxWsServerFactoryBean();
            svrFactory.setAddress("http://localhost:" + SERVICE_PORT + "/Hello2");
            svrFactory.setServiceBean(greeter2);
            svrFactory.getProperties(true).put("managed.endpoint.name", "greeter2");
            svrFactory.create();
           
            MBeanServer mbs = im.getMBeanServer();
           
            ObjectName name = new ObjectName(ManagementConstants.DEFAULT_DOMAIN_NAME
                                             + ":type=Bus.Service.Endpoint,*");
 
View Full Code Here

        return newClient;
    }

    public static Server createServer(Class<?> serviceInterface, Object serviceImpl, Feature ... features)
        throws IOException {
        JaxWsServerFactoryBean svrFactory = new JaxWsServerFactoryBean();
        svrFactory.setServiceClass(serviceImpl.getClass());
        if (features != null) {
            svrFactory.getFeatures().addAll(Arrays.asList(features));
        }
        svrFactory.setAddress(getAddress(serviceInterface));
        svrFactory.setServiceBean(serviceImpl);
        Server server = svrFactory.create();
        serverList.add(server);
        return server;
    }
View Full Code Here

public class PolicyAnnotationTest extends Assert {

    @org.junit.Test
    public void testAnnotations() throws Exception {
        Bus bus = BusFactory.getDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceBean(new TestImpl());
        factory.setStart(false);
        List<String> tp = Arrays.asList(
            "http://schemas.xmlsoap.org/soap/http",
            "http://schemas.xmlsoap.org/wsdl/http/",
            "http://schemas.xmlsoap.org/wsdl/soap/http",
            "http://www.w3.org/2003/05/soap/bindings/HTTP/",
            "http://cxf.apache.org/transports/http/configuration",
            "http://cxf.apache.org/bindings/xformat");
       
        LocalTransportFactory f = new LocalTransportFactory(bus);
        f.getUriPrefixes().add("http");
        f.setTransportIds(tp);
        f.setBus(bus);
        f.register();
       
       
        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus,
                                                                s.getEndpoint().getService()
                                                                    .getServiceInfos());
View Full Code Here

    }

    @org.junit.Test
    public void testAnnotationsInterfaceAsClass() throws Exception {
        Bus bus = BusFactory.getDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceBean(new TestImpl());
        factory.setServiceClass(TestInterface.class);
        factory.setStart(false);
        List<String> tp = Arrays.asList(
            "http://schemas.xmlsoap.org/soap/http",
            "http://schemas.xmlsoap.org/wsdl/http/",
            "http://schemas.xmlsoap.org/wsdl/soap/http",
            "http://www.w3.org/2003/05/soap/bindings/HTTP/",
            "http://cxf.apache.org/transports/http/configuration",
            "http://cxf.apache.org/bindings/xformat");
       
        LocalTransportFactory f = new LocalTransportFactory(bus);
        f.getUriPrefixes().add("http");
        f.setTransportIds(tp);
        f.setBus(bus);
        f.register();
       
       
        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus,
                                                                s.getEndpoint().getService()
                                                                    .getServiceInfos());
View Full Code Here

    }

    @org.junit.Test
    public void testAnnotationImplNoInterface() throws Exception {
        Bus bus = BusFactory.getDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceBean(new TestImplNoInterface());
        factory.setStart(false);
        List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/",
                "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/",
                "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");

        LocalTransportFactory f = new LocalTransportFactory();
        f.getUriPrefixes().add("http");
        f.setTransportIds(tp);

        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
            Definition def = builder.build();
            WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
View Full Code Here

    }

    @org.junit.Test
    public void testAnnotationImplNoInterfacePolicies() throws Exception {
        Bus bus = BusFactory.getDefaultBus();
        JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceBean(new TestImplWithPoliciesNoInterface());
        factory.setStart(false);
        List<String> tp = Arrays.asList("http://schemas.xmlsoap.org/soap/http", "http://schemas.xmlsoap.org/wsdl/http/",
                "http://schemas.xmlsoap.org/wsdl/soap/http", "http://www.w3.org/2003/05/soap/bindings/HTTP/",
                "http://cxf.apache.org/transports/http/configuration", "http://cxf.apache.org/bindings/xformat");

        LocalTransportFactory f = new LocalTransportFactory();
        f.getUriPrefixes().add("http");
        f.setTransportIds(tp);

        Server s = factory.create();

        try {
            ServiceWSDLBuilder builder = new ServiceWSDLBuilder(bus, s.getEndpoint().getService().getServiceInfos());
            Definition def = builder.build();
            WSDLWriter wsdlWriter = bus.getExtension(WSDLManager.class).getWSDLFactory().newWSDLWriter();
View Full Code Here

        return new SpringBusFactory().createBus("/org/apache/cxf/systest/ws/addressing/spring/spring.xml");
    }

    @Test
    public void testServerFactory() {
        JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
    
        assert bus != null;
        sf.setServiceBean(new GreeterImpl());
        sf.setAddress("http://localhost:" + PORT + "/test");
        sf.setStart(false);
       
        Configurer c = getBus().getExtension(Configurer.class);
        c.configureBean("server", sf);
       
        Server server = sf.create();
       
        Endpoint endpoint = server.getEndpoint();
        checkAddressInterceptors(endpoint.getInInterceptors());
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxws.JaxWsServerFactoryBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.