Search in sources :

Example 1 with WSHTTPConnection

use of com.sun.xml.ws.transport.http.WSHTTPConnection 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 2 with WSHTTPConnection

use of com.sun.xml.ws.transport.http.WSHTTPConnection in project metro-jax-ws by eclipse-ee4j.

the class ServletAdapter method invokeAsync.

/**
 * Version of {@link #handle(WSHTTPConnection)}  that takes convenient parameters for servlet.
 *
 * Based on the async capabilities of the request and the application processing it, the method may run in asynchronous mode.
 * When run in async mode, this method returns immediately. The response is delayed until the application is ready with the response or
 *  the corresponding asynchronous operation times out. The CompletionCallback is guaranteed to run after response is committed..
 *
 * @param context Servlet Context
 * @param request Servlet Request
 * @param response Servlet Response
 * @param callback CompletionCallback
 * @throws IOException when there is i/o error in handling request
 */
public void invokeAsync(ServletContext context, HttpServletRequest request, HttpServletResponse response, final CompletionCallback callback) throws IOException {
    boolean asyncStarted = false;
    try {
        WSHTTPConnection connection = new ServletConnectionImpl(this, context, request, response);
        if (handleGet(connection)) {
            return;
        }
        boolean asyncRequest = false;
        try {
            asyncRequest = isServlet30Based && request.isAsyncSupported() && !request.isAsyncStarted();
        } catch (Throwable t) {
            // this happens when the loaded Servlet API is 3.0, but the impl is not, ending up as AbstractMethodError
            LOGGER.log(Level.INFO, request.getClass().getName() + " does not support Async API, Continuing with synchronous processing", t);
            // Continue with synchronous processing and don't repeat the check for processing further requests
            isServlet30Based = false;
        }
        if (asyncRequest) {
            final jakarta.servlet.AsyncContext asyncContext = request.startAsync(request, response);
            final AsyncCompletionCheck completionCheck = new AsyncCompletionCheck();
            new WSAsyncListener(connection, callback).addListenerTo(asyncContext, completionCheck);
            // asyncContext.setTimeout(10000L);// TODO get it from @ or config file
            super.invokeAsync(connection, new CompletionCallback() {

                @Override
                public void onCompletion() {
                    synchronized (completionCheck) {
                        if (!completionCheck.isCompleted()) {
                            asyncContext.complete();
                            completionCheck.markComplete();
                        }
                    }
                }
            });
            asyncStarted = true;
        } else {
            super.handle(connection);
        }
    } finally {
        if (!asyncStarted) {
            callback.onCompletion();
        }
    }
}
Also used : WSHTTPConnection(com.sun.xml.ws.transport.http.WSHTTPConnection)

Example 3 with WSHTTPConnection

use of com.sun.xml.ws.transport.http.WSHTTPConnection in project metro-jax-ws by eclipse-ee4j.

the class ServletAdapter method publishWSDL.

/**
 * @param context Servlet Context
 * @param request Servlet Request
 * @param response Servlet Response
 * @throws IOException when there is i/o error in handling request
 *
 * @deprecated
 *      Use {@link #handle(ServletContext, HttpServletRequest, HttpServletResponse)}
 */
public void publishWSDL(ServletContext context, HttpServletRequest request, HttpServletResponse response) throws IOException {
    WSHTTPConnection connection = new ServletConnectionImpl(this, context, request, response);
    super.handle(connection);
}
Also used : WSHTTPConnection(com.sun.xml.ws.transport.http.WSHTTPConnection)

Aggregations

WSHTTPConnection (com.sun.xml.ws.transport.http.WSHTTPConnection)3 Packet (com.sun.xml.ws.api.message.Packet)1 BoundEndpoint (com.sun.xml.ws.api.server.BoundEndpoint)1 DocumentAddressResolver (com.sun.xml.ws.api.server.DocumentAddressResolver)1 PortAddressResolver (com.sun.xml.ws.api.server.PortAddressResolver)1 SDDocument (com.sun.xml.ws.api.server.SDDocument)1 WSEndpoint (com.sun.xml.ws.api.server.WSEndpoint)1 WebModule (com.sun.xml.ws.api.server.WebModule)1 HttpAdapter (com.sun.xml.ws.transport.http.HttpAdapter)1 HttpAdapterList (com.sun.xml.ws.transport.http.HttpAdapterList)1 DataChunk (io.helidon.common.http.DataChunk)1 Http (io.helidon.common.http.Http)1 IoMulti (io.helidon.common.reactive.IoMulti)1 MultiFromOutputStream (io.helidon.common.reactive.MultiFromOutputStream)1 PathMatcher (io.helidon.webserver.PathMatcher)1 ServerRequest (io.helidon.webserver.ServerRequest)1 ServerResponse (io.helidon.webserver.ServerResponse)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1