Example usage for javax.xml.ws Endpoint stop

List of usage examples for javax.xml.ws Endpoint stop

Introduction

In this page you can find the example usage for javax.xml.ws Endpoint stop.

Prototype

public abstract void stop();

Source Link

Document

Stops publishing this endpoint.

Usage

From source file:ru.codeinside.gws.core.sproto.R120315_Metro_Test.java

@Test
public void testValidationIn() throws IOException {
    String portAddr = "http://127.0.0.1:7772/";
    Endpoint endpoint = Endpoint.publish(portAddr, new Router(null));
    try {/*from   w w  w .  j  a  va  2s  . c o  m*/
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) new URL(portAddr).openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("fss-request-1.xml"), con.getOutputStream());
        assertEquals(500, con.getResponseCode());
        String error = IOUtils.toString(con.getErrorStream(), "UTF8");
        assertTrue(error.contains("Cannot find the declaration of element 'ws:request'"));
    } finally {
        endpoint.stop();
    }
}

From source file:ru.codeinside.gws.core.sproto.R120315_Metro_Test.java

@Test
public void testValidationOut() throws IOException {
    final AtomicReference<ServerRequest> request = new AtomicReference<ServerRequest>();
    String portAddr = "http://127.0.0.1:7773/";
    Endpoint endpoint = Endpoint.publish(portAddr, new Router(new Invoker() {
        @Override/*from   ww  w . j a v a  2s.c o  m*/
        public SOAPMessage invoke(SOAPMessage in, WebServiceContext ctx) {
            CryptoProvider cryptoProvider = mock(CryptoProvider.class);
            R120315 r120315 = new R120315(cryptoProvider);
            request.set(r120315.processRequest(in, mvvPort.service, mvvPort.portDef));
            try {
                return R.getSoapResource("fss-response-2.xml");
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }));
    try {
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) new URL(portAddr).openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("mvvact/updateStatus/UpdateStatus_request.xml"),
                con.getOutputStream());
        assertEquals(500, con.getResponseCode());
        String error = IOUtils.toString(con.getErrorStream(), "UTF8");
        assertTrue(error.contains("Cannot find the declaration of element 'ns3:requestResponse'"));

        ServerRequest req = request.get();
        assertNull(req.routerPacket);
        assertEquals(new QName("http://mvv.oep.com/", "updateStatus"), req.action);
        assertNull(req.packet.serviceName);
        assertEquals(Packet.Type.SERVICE, req.packet.typeCode);
        assertEquals(Packet.Status.REQUEST, req.packet.status);
        assertEquals("Test", req.packet.exchangeType);
        assertEquals("11111111111", req.packet.requestIdRef);
        assertEquals("111111111111", req.packet.originRequestIdRef);
        assertEquals("1111111111", req.packet.serviceCode);
        assertEquals("1111111111111", req.packet.caseNumber);
        assertNull(req.attachmens);
        assertNull(req.docRequestCode);

    } finally {
        endpoint.stop();
    }
}