Search in sources :

Example 56 with Endpoint

use of jakarta.xml.ws.Endpoint in project metro-jax-ws by eclipse-ee4j.

the class ProviderTester method testProviderEndpoint.

public void testProviderEndpoint() {
    int port = Util.getFreePort();
    String address = "http://127.0.0.1:" + port + "/";
    Endpoint e = Endpoint.create(HTTPBinding.HTTP_BINDING, new MyProvider());
    e.publish(address);
    // TODO add dispatch client to access this endpoint
    e.stop();
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) Endpoint(jakarta.xml.ws.Endpoint)

Example 57 with Endpoint

use of jakarta.xml.ws.Endpoint in project metro-jax-ws by eclipse-ee4j.

the class SchemaRedefineTester method testSchemaRedefine.

public void testSchemaRedefine() throws Exception {
    int port = Util.getFreePort();
    port = 1666;
    String address = "http://localhost:" + port + "/redefine";
    Endpoint e = Endpoint.create(new RedefineProvider());
    List<Source> metadata = new ArrayList<Source>();
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    String[] docs = { "WEB-INF/wsdl/SchemaRedefine.wsdl", "WEB-INF/wsdl/SchemaRedefine.xsd" };
    for (String doc : docs) {
        URL url = cl.getResource(doc);
        metadata.add(new StreamSource(url.openStream(), url.toExternalForm()));
    }
    e.setMetadata(metadata);
    e.publish(address);
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader = factory.createXMLStreamReader(new URL(address + "?wsdl").openStream());
    while (reader.hasNext()) {
        reader.next();
        if (reader.getEventType() == XMLStreamConstants.START_ELEMENT && reader.getLocalName().equals("redefine")) {
            String loc = reader.getAttributeValue(null, "schemaLocation");
            assertEquals(address + "?xsd=1", loc);
        }
    }
    e.stop();
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) ArrayList(java.util.ArrayList) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) DataSource(jakarta.activation.DataSource) URL(java.net.URL) Endpoint(jakarta.xml.ws.Endpoint)

Example 58 with Endpoint

use of jakarta.xml.ws.Endpoint in project metro-jax-ws by eclipse-ee4j.

the class SourceTester method testSource.

public void testSource() throws Exception {
    int port = Util.getFreePort();
    String address = "http://localhost:" + port + "/source";
    Endpoint endpoint = Endpoint.create(new SourceEndpoint());
    endpoint.publish(address);
    Source response = invoke(address);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.transform(response, new StreamResult(bos));
    bos.close();
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader = factory.createXMLStreamReader(new ByteArrayInputStream(bos.toByteArray()));
    while (reader.hasNext()) {
        reader.next();
    }
    endpoint.stop();
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) Endpoint(jakarta.xml.ws.Endpoint) StreamResult(javax.xml.transform.stream.StreamResult) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 59 with Endpoint

use of jakarta.xml.ws.Endpoint in project metro-jax-ws by eclipse-ee4j.

the class WhitespaceTester method testSource.

public void testSource() throws Exception {
    int port = Util.getFreePort();
    String address = "http://localhost:" + port + "/source";
    Endpoint endpoint = Endpoint.create(new WhitespaceEndpoint());
    endpoint.publish(address);
    Source response = invoke(address);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.transform(response, new StreamResult(bos));
    bos.close();
    assertTrue(new String(bos.toByteArray()).contains("30"));
    endpoint.stop();
}
Also used : TransformerFactory(javax.xml.transform.TransformerFactory) Transformer(javax.xml.transform.Transformer) Endpoint(jakarta.xml.ws.Endpoint) StreamResult(javax.xml.transform.stream.StreamResult) Endpoint(jakarta.xml.ws.Endpoint) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source)

Example 60 with Endpoint

use of jakarta.xml.ws.Endpoint in project metro-jax-ws by eclipse-ee4j.

the class EnumTester method testEnum.

public void testEnum() throws Exception {
    int port = Util.getFreePort();
    String address = "http://localhost:" + port + "/enum";
    Endpoint endpoint = Endpoint.create(new EnumEndpoint());
    endpoint.publish(address);
    String response = invoke(address, 2);
    assertTrue(response.contains("Blue"));
    response = invoke(address, 5);
    assertTrue(response.contains("Red"));
    endpoint.stop();
}
Also used : Endpoint(jakarta.xml.ws.Endpoint) Endpoint(jakarta.xml.ws.Endpoint)

Aggregations

Endpoint (jakarta.xml.ws.Endpoint)90 URL (java.net.URL)25 Source (javax.xml.transform.Source)22 StreamSource (javax.xml.transform.stream.StreamSource)22 ArrayList (java.util.ArrayList)16 MemberSubmissionEndpointReference (com.sun.xml.ws.developer.MemberSubmissionEndpointReference)10 W3CEndpointReference (jakarta.xml.ws.wsaddressing.W3CEndpointReference)10 QName (javax.xml.namespace.QName)7 HttpContext (com.sun.net.httpserver.HttpContext)6 HttpServer (com.sun.net.httpserver.HttpServer)5 InetSocketAddress (java.net.InetSocketAddress)5 HashMap (java.util.HashMap)5 ExecutorService (java.util.concurrent.ExecutorService)5 HTTPResponseInfo (testutil.HTTPResponseInfo)5 EndpointImpl (com.sun.xml.ws.transport.http.server.EndpointImpl)4 EndpointReference (jakarta.xml.ws.EndpointReference)4 Transformer (javax.xml.transform.Transformer)4 TransformerFactory (javax.xml.transform.TransformerFactory)4 StreamResult (javax.xml.transform.stream.StreamResult)4 WSEndpoint (com.sun.xml.ws.api.server.WSEndpoint)3