Package org.reficio.ws.server.core

Examples of org.reficio.ws.server.core.SoapServer


*/
public class SoapServerExamplesTest {

    @Test
    public void createServer() {
        SoapServer server = SoapServer.builder()
                .httpPort(9090)
                .build();
        server.start();
        server.stop();
    }
View Full Code Here


        server.stop();
    }

    @Test
    public void createServer_registerAutoResponder() throws WSDLException {
        SoapServer server = SoapServer.builder()
                .httpPort(9090)
                .build();
        server.start();

        URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl");
        Wsdl parser = Wsdl.parse(wsdlUrl);
        SoapBuilder builder = parser.binding().localPart("StockQuoteSoapBinding").find();
        AutoResponder responder = new AutoResponder(builder);

        server.registerRequestResponder("/service", responder);
        server.stop();
    }
View Full Code Here

        server.stop();
    }

    @Test
    public void createServer_registerCustomResponder() throws WSDLException {
        SoapServer server = SoapServer.builder()
                .httpPort(9090)
                .build();
        server.start();

        URL wsdlUrl = ResourceUtils.getResourceWithAbsolutePackagePath("/", "wsdl/stockquote-service.wsdl");
        Wsdl parser = Wsdl.parse(wsdlUrl);
        final SoapBuilder builder = parser.binding().localPart("StockQuoteSoapBinding").find();

        AbstractResponder customResponder = new AbstractResponder(builder) {
            @Override
            public Source respond(SoapOperation invokedOperation, SoapMessage message) {
                try {
                    // build the response using builder
                    String response = builder.buildOutputMessage(invokedOperation);
                    // here you can tweak the response -> for example with XSLT
                    //...
                    return XmlUtils.xmlStringToSource(response);
                } catch (Exception e) {
                    // will automatically generate SOAP-FAULT
                    throw new RuntimeException("my custom error", e);
                }
            }
        };

        server.registerRequestResponder("/service", customResponder);
        server.stop();
    }
View Full Code Here

        }
        throw new SoapServerException("Crazy stuff is happening, no free port available");
    }

    public static SoapServer getServer() {
        SoapServer server = SoapServer.builder()
                .httpPort(getFreePort())
                .build();
        return server;
    }
View Full Code Here

    @Test
    public void startStop() {
        int port = getFreePort();
        assertTrue(isPortAvailable(port));
        SoapServer server = SoapServer.builder()
                .httpPort(port)
                .build();
        server.start();
        assertFalse(isPortAvailable(port));
        server.stop();
        assertTrue(isPortAvailable(port));
    }
View Full Code Here

        assertTrue(isPortAvailable(port));
    }

    @Test
    public void startStopDestroy() {
        SoapServer server = getServer();
        server.start();
        server.stop();
        server.destroy();
    }
View Full Code Here

        server.destroy();
    }

    @Test
    public void startStopDestroyCannotResurrect() {
        SoapServer server = getServer();
        server.start();
        server.stop();
        server.destroy();
        RuntimeException caught = null;
        try {
            server.start();
        } catch (RuntimeException ex) {
            caught = ex;
        }
        assertNotNull(caught);
    }
View Full Code Here

    }

    @Test
    public void registerCheck() {
        String contextPath = "/test";
        SoapServer server = getServer();
        server.registerRequestResponder(contextPath, new RequestResponder() {
            @Override
            public Source respond(SoapMessage message) {
                return null;
            }
        });
        List<String> paths = server.getRegisteredContextPaths();
        assertEquals(paths.size(), 1);
        assertEquals(paths.toArray(new String[]{})[0], contextPath);
    }
View Full Code Here

    }

    @Test
    public void unregisterCheck() {
        String contextPath = "/test";
        SoapServer server = getServer();
        server.registerRequestResponder(contextPath, new RequestResponder() {
            @Override
            public Source respond(SoapMessage message) {
                return null;
            }
        });
        server.unregisterRequestResponder(contextPath);
        List<String> paths = server.getRegisteredContextPaths();
        assertEquals(paths.size(), 0);
    }
View Full Code Here

    }

    @Test(expected = ServiceRegistrationException.class)
    public void doubleRegister() {
        String contextPath = "/test";
        SoapServer server = getServer();
        server.registerRequestResponder(contextPath, new RequestResponder() {
            @Override
            public Source respond(SoapMessage message) {
                return null;
            }
        });
        server.registerRequestResponder(contextPath, new RequestResponder() {
            @Override
            public Source respond(SoapMessage message) {
                return null;
            }
        });
View Full Code Here

TOP

Related Classes of org.reficio.ws.server.core.SoapServer

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.