Example usage for javax.xml.ws Endpoint isPublished

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

Introduction

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

Prototype

public abstract boolean isPublished();

Source Link

Document

Returns true if the endpoint is in the published state.

Usage

From source file:de.intevation.test.irixservice.UploadReportTest.java

/**
 * Test that the webservice can be created and accepts a valid report.
 *//*from ww  w .j  a  v a  2  s .  c om*/
@Test
public void testServiceCreated() throws MalformedURLException, IOException, UploadReportException {
    Endpoint endpoint = Endpoint.publish("http://localhost:18913/upload-report", testObj);
    Assert.assertTrue(endpoint.isPublished());
    Assert.assertEquals("http://schemas.xmlsoap.org/wsdl/soap/http", endpoint.getBinding().getBindingID());

    URL wsdlDocumentLocation = new URL("http://localhost:18913/upload-report?wsdl");
    String namespaceURI = "http://irixservice.intevation.de/";
    String servicePart = "UploadReportService";
    String portName = "UploadReportPort";
    QName serviceQN = new QName(namespaceURI, servicePart);
    QName portQN = new QName(namespaceURI, portName);

    Service serv = Service.create(wsdlDocumentLocation, serviceQN);
    UploadReportInterface service = serv.getPort(portQN, UploadReportInterface.class);
    ReportType report = getReportFromFile(VALID_REPORT);
    service.uploadReport(report);
    String uuid = report.getIdentification().getReportUUID();
    String expectedPath = testObj.outputDir + "/" + uuid + ".xml";
    Assert.assertTrue(new File(expectedPath).exists());
}

From source file:org.nuxeo.ecm.platform.ws.WSEndpointManagerImpl.java

@Override
public void publishEndpoints() {
    for (WSEndpointDescriptor desc : regitry.getContributions()) {
        try {//from  ww w  .j  a  v a 2  s  .c  om
            stopIfExists(desc.name);

            Endpoint ep = desc.toEndpoint();

            ep.publish(desc.address);
            desc.configurePostPublishing(ep);

            if (ep.isPublished()) {
                endpoints.put(desc.name, ep);
            } else {
                log.warn("Endpoint publishing is failing: " + desc.name);
            }
        } catch (IOException | IllegalAccessException | InstantiationException e) {
            log.warn("Unable to register endpoint: " + desc.name, e);
        }
    }
}

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

@Test
public void testRequestParsing() throws IOException {
    final URL addr = new URL("http://127.0.0.1:7771/");
    final AtomicReference<ServerRequest> request = new AtomicReference<ServerRequest>();
    Endpoint endpoint = Endpoint.publish("http://127.0.0.1:7771/", new Router(new Invoker() {
        @Override/*from w  w  w. j av 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));

            ServerResponse response = new ServerResponse();
            response.action = new QName("http://mvv.oep.com/", "putData");
            Packet p = new Packet();
            response.packet = p;
            p.exchangeType = "Test";
            p.serviceCode = "111111111111";
            p.requestIdRef = "111111111111";
            p.originRequestIdRef = "111111111111";
            p.caseNumber = "111111111111";
            p.typeCode = Packet.Type.SERVICE;
            p.status = Packet.Status.PROCESS;
            p.recipient = p.sender = new InfoSystem("PNZR01581", "111111111");
            p.date = new Date();

            return r120315.processResponse(null, response, mvvPort.service, mvvPort.portDef, null);
        }
    }));
    try {
        assertTrue(endpoint.isPublished());
        HttpURLConnection con = (HttpURLConnection) addr.openConnection();
        con.setRequestProperty("Content-type", "text/xml; charset=utf-8");
        con.setDoOutput(true);
        con.setDoInput(true);
        IOUtils.copy(R.getRequiredResourceStream("mvvact/putData/request.xml"), con.getOutputStream());
        String result = IOUtils.toString(con.getInputStream(), "UTF8");
        assertNotNull(result);

        ServerRequest req = request.get();

        assertNull(req.routerPacket);
        assertEquals(new QName("http://mvv.oep.com/", "putData"), req.action);
        assertEquals("UniversalMVV", req.packet.serviceName);
        assertEquals(Packet.Type.SERVICE, req.packet.typeCode);
        assertEquals(Packet.Status.REQUEST, req.packet.status);
        assertEquals("Test", req.packet.exchangeType);
        assertEquals("111111111111", req.packet.requestIdRef);
        assertEquals("111111111111", req.packet.originRequestIdRef);
        assertEquals("111111111111", req.packet.serviceCode);
        assertEquals("111111111111", req.packet.caseNumber);
        assertNull(req.attachmens);
        assertNull(req.docRequestCode);
    } finally {
        endpoint.stop();
    }
}

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 {/*  ww w . j  av a  2 s  .com*/
        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 w  ww  .  jav a2s.c om*/
        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();
    }
}

From source file:test.unit.be.fedict.trust.xkms2.XKMSPortImplTest.java

@Test
public void test() throws Exception {
    int port = getFreePort();
    String address = "http://localhost:" + port + "/xkms2";
    HttpServer server = HttpServer.create(new InetSocketAddress("localhost", port), 5);
    ExecutorService threads = Executors.newFixedThreadPool(5);
    server.setExecutor(threads);/*from  w  w  w .ja  v  a  2s  .  c  o m*/
    server.start();

    XKMSPortType xkmsPort = new XKMSPortImpl();
    Endpoint endpoint = Endpoint.create(xkmsPort);

    HttpContext httpContext = server.createContext("/xkms2");
    LOG.debug("http context attributes: " + httpContext.getAttributes());
    endpoint.publish(httpContext);

    assertTrue(endpoint.isPublished());

    HttpClient httpClient = new HttpClient();
    GetMethod getMethod = new GetMethod(address + "?wsdl");
    int statusCode = httpClient.executeMethod(getMethod);
    LOG.debug("status code: " + statusCode);
    assertEquals(HttpServletResponse.SC_OK, statusCode);
    LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString());

    getMethod = new GetMethod(address + "?wsdl=1");
    statusCode = httpClient.executeMethod(getMethod);
    LOG.debug("status code: " + statusCode);
    assertEquals(HttpServletResponse.SC_OK, statusCode);
    LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString());

    XKMSService xkmsService = XKMSServiceFactory.getInstance();
    XKMSPortType xkmsPortClient = xkmsService.getXKMSPort();
    BindingProvider bindingProviderClient = (BindingProvider) xkmsPortClient;
    bindingProviderClient.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);

    // EasyMock.replay(mockServletContext);
    // ValidateResultType validateResult = xkmsPortClient.validate(null);
    // EasyMock.verify(mockServletContext);
}