Search in sources :

Example 6 with SDDocument

use of com.sun.xml.ws.api.server.SDDocument in project metro-jax-ws by eclipse-ee4j.

the class HelidonAdapter method publishWSDLX.

public void publishWSDLX(WSHTTPConnection c) throws IOException {
    // res.status(Http.Status.OK_200);
    // res.headers().add("Content-Type", Collections.singletonList("text/xml;charset=utf-8"));
    // res.send();
    HelidonConnectionImpl con = (HelidonConnectionImpl) c;
    // con.getInput().close();
    SDDocument doc = wsdls.get(con.getQueryString());
    if (doc == null) {
        // writeNotFoundErrorPage(con,"Invalid Request");
        return;
    }
    // con.req.
    ServerResponse res = con.getResponse();
    res.status(Http.Status.OK_200);
    res.headers().add("Content-Type", Collections.singletonList("text/xml;charset=utf-8"));
    // res.send(con.getOutput(), OutputStream.class);
    // res.send("<s>hello</s>");
    // con.setStatus(HttpURLConnection.HTTP_OK);
    // con.setContentTypeResponseHeader("text/xml;charset=utf-8");
    // 
    // //        OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
    // //con.res.
    // OutputStream os = con.getOutput();
    // OutputStream os = new ByteArrayOutputStream();
    MultiFromOutputStream os = IoMulti.outputStreamMulti();
    PortAddressResolver portAddressResolver = getPortAddressResolver(con.getBaseAddress());
    DocumentAddressResolver resolver = getDocumentAddressResolver(portAddressResolver);
    res.send(os.map(byteBuffer -> DataChunk.create(false, true, byteBuffer)));
    doc.writeTo(portAddressResolver, resolver, os);
    // con.res.send(() -> {
    // });
    os.close();
}
Also used : ServerResponse(io.helidon.webserver.ServerResponse) WebModule(com.sun.xml.ws.api.server.WebModule) IoMulti(io.helidon.common.reactive.IoMulti) DataChunk(io.helidon.common.http.DataChunk) URISyntaxException(java.net.URISyntaxException) MultiFromOutputStream(io.helidon.common.reactive.MultiFromOutputStream) DocumentAddressResolver(com.sun.xml.ws.api.server.DocumentAddressResolver) IOException(java.io.IOException) SDDocument(com.sun.xml.ws.api.server.SDDocument) Logger(java.util.logging.Logger) ServerRequest(io.helidon.webserver.ServerRequest) Level(java.util.logging.Level) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) HttpAdapterList(com.sun.xml.ws.transport.http.HttpAdapterList) PathMatcher(io.helidon.webserver.PathMatcher) PortAddressResolver(com.sun.xml.ws.api.server.PortAddressResolver) WSHTTPConnection(com.sun.xml.ws.transport.http.WSHTTPConnection) ServerResponse(io.helidon.webserver.ServerResponse) Packet(com.sun.xml.ws.api.message.Packet) BoundEndpoint(com.sun.xml.ws.api.server.BoundEndpoint) URI(java.net.URI) Http(io.helidon.common.http.Http) Collections(java.util.Collections) HttpAdapter(com.sun.xml.ws.transport.http.HttpAdapter) PortAddressResolver(com.sun.xml.ws.api.server.PortAddressResolver) MultiFromOutputStream(io.helidon.common.reactive.MultiFromOutputStream) SDDocument(com.sun.xml.ws.api.server.SDDocument) DocumentAddressResolver(com.sun.xml.ws.api.server.DocumentAddressResolver)

Example 7 with SDDocument

use of com.sun.xml.ws.api.server.SDDocument in project metro-jax-ws by eclipse-ee4j.

the class WSDLGen method run.

public static int run() throws Exception {
    if (!useLocal()) {
        return 0;
    }
    String outputDir = System.getProperty("tempdir");
    if (outputDir == null) {
        System.err.println("**** Set tempdir system property ****");
        return -1;
    }
    String riFile = outputDir + "/WEB-INF/sun-jaxws.xml";
    DeploymentDescriptorParser<WSEndpoint> parser = new DeploymentDescriptorParser<WSEndpoint>(Thread.currentThread().getContextClassLoader(), new FileSystemResourceLoader(new File(outputDir)), null, new AdapterFactory<WSEndpoint>() {

        public WSEndpoint createAdapter(String name, String urlPattern, WSEndpoint<?> endpoint) {
            return endpoint;
        }
    });
    List<WSEndpoint> endpoints = parser.parse(new File(riFile));
    final String addr = new File(outputDir).toURL().toExternalForm();
    // file:// -> local://
    final String address = "local" + addr.substring(4);
    for (WSEndpoint endpoint : endpoints) {
        ServiceDefinition def = endpoint.getServiceDefinition();
        if (def == null) {
            continue;
        }
        SDDocument primary = def.getPrimary();
        File file = new File(primary.getURL().toURI());
        if (file.exists()) {
            System.out.println("**** Primary WSDL " + file + " already exists - not generating any WSDL artifacts ****");
            // Primary WSDL already exists
            continue;
        }
        for (SDDocument doc : def) {
            int index = doc.getURL().getFile().indexOf("/WEB-INF/wsdl");
            String name = "";
            if (index == -1)
                name = outputDir + "/WEB-INF/wsdl" + doc.getURL().getFile();
            else
                name = doc.getURL().getFile();
            System.out.println("Creating WSDL artifact=" + name);
            ByteArrayBuffer buffer = new ByteArrayBuffer();
            doc.writeTo(new PortAddressResolver() {

                public String getAddressFor(QName serviceName, String portName) {
                    return address;
                }
            }, new DocumentAddressResolver() {

                public String getRelativeAddressFor(SDDocument current, SDDocument referenced) {
                    String rel = referenced.getURL().toExternalForm();
                    // remove file:/
                    return rel.substring(6);
                }
            }, buffer);
            FileOutputStream fos = new FileOutputStream(name);
            buffer.writeTo(fos);
            fos.close();
        }
    }
    return 0;
}
Also used : PortAddressResolver(com.sun.xml.ws.api.server.PortAddressResolver) DeploymentDescriptorParser(com.sun.xml.ws.transport.http.DeploymentDescriptorParser) QName(javax.xml.namespace.QName) FileSystemResourceLoader(com.sun.xml.ws.transport.local.FileSystemResourceLoader) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) DocumentAddressResolver(com.sun.xml.ws.api.server.DocumentAddressResolver) ByteArrayBuffer(com.sun.xml.ws.util.ByteArrayBuffer) WSEndpoint(com.sun.xml.ws.api.server.WSEndpoint) FileOutputStream(java.io.FileOutputStream) SDDocument(com.sun.xml.ws.api.server.SDDocument) File(java.io.File) ServiceDefinition(com.sun.xml.ws.api.server.ServiceDefinition)

Aggregations

SDDocument (com.sun.xml.ws.api.server.SDDocument)7 DocumentAddressResolver (com.sun.xml.ws.api.server.DocumentAddressResolver)3 PortAddressResolver (com.sun.xml.ws.api.server.PortAddressResolver)3 SDDocumentSource (com.sun.xml.ws.api.server.SDDocumentSource)2 WSEndpoint (com.sun.xml.ws.api.server.WSEndpoint)2 ByteArrayBuffer (com.sun.xml.ws.util.ByteArrayBuffer)2 IOException (java.io.IOException)2 Source (javax.xml.transform.Source)2 DOMSource (javax.xml.transform.dom.DOMSource)2 StreamSource (javax.xml.transform.stream.StreamSource)2 Document (org.w3c.dom.Document)2 Component (com.sun.xml.ws.api.Component)1 Packet (com.sun.xml.ws.api.message.Packet)1 BoundEndpoint (com.sun.xml.ws.api.server.BoundEndpoint)1 ServiceDefinition (com.sun.xml.ws.api.server.ServiceDefinition)1 WebModule (com.sun.xml.ws.api.server.WebModule)1 DeploymentDescriptorParser (com.sun.xml.ws.transport.http.DeploymentDescriptorParser)1 HttpAdapter (com.sun.xml.ws.transport.http.HttpAdapter)1 HttpAdapterList (com.sun.xml.ws.transport.http.HttpAdapterList)1 WSHTTPConnection (com.sun.xml.ws.transport.http.WSHTTPConnection)1