Search in sources :

Example 1 with HTTPBinding

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

the class WSServletDelegate method doPut.

/**
 * Handles HTTP PUT for XML/HTTP binding based endpoints
 *
 * @param request the HTTP request object
 * @param response the HTTP response object
 * @param context servlet context
 */
public void doPut(HttpServletRequest request, HttpServletResponse response, ServletContext context) {
    // TODO: unify this into doGet.
    try {
        EndpointAdapter target = getTarget(request);
        if (target != null) {
            if (logger.isLoggable(Level.FINEST)) {
                logger.log(Level.FINEST, "Got request for endpoint {0}", target.getUrlPattern());
            }
        } else {
            writeNotFoundErrorPage(response, "Invalid request");
            return;
        }
        Binding binding = target.getEndpoint().getBinding();
        if (binding instanceof HTTPBinding) {
            target.handle(context, request, response);
        } else {
            response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        }
    } catch (WebServiceException e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Throwable e) {
        logger.log(Level.SEVERE, "caught throwable", e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
Also used : Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) WebServiceException(jakarta.xml.ws.WebServiceException) HTTPBinding(jakarta.xml.ws.http.HTTPBinding)

Example 2 with HTTPBinding

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

the class HttpAdapter method handleGet.

public boolean handleGet(@NotNull WSHTTPConnection connection) throws IOException {
    if (connection.getRequestMethod().equals("GET")) {
        // metadata query. let the interceptor run
        for (Component c : endpoint.getComponents()) {
            HttpMetadataPublisher spi = c.getSPI(HttpMetadataPublisher.class);
            if (spi != null && spi.handleMetadataRequest(this, connection)) {
                return true;
            }
        // handled
        }
        if (isMetadataQuery(connection.getQueryString())) {
            // Sends published WSDL and schema documents as the default action.
            publishWSDL(connection);
            return true;
        }
        Binding binding = getEndpoint().getBinding();
        if (!(binding instanceof HTTPBinding)) {
            // Writes HTML page with all the endpoint descriptions
            writeWebServicesHtmlPage(connection);
            return true;
        }
    } else if (connection.getRequestMethod().equals("HEAD")) {
        connection.getInput().close();
        Binding binding = getEndpoint().getBinding();
        if (isMetadataQuery(connection.getQueryString())) {
            SDDocument doc = wsdls.get(connection.getQueryString());
            connection.setStatus(doc != null ? HttpURLConnection.HTTP_OK : HttpURLConnection.HTTP_NOT_FOUND);
            connection.getOutput().close();
            connection.close();
            return true;
        } else if (!(binding instanceof HTTPBinding)) {
            connection.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
            connection.getOutput().close();
            connection.close();
            return true;
        }
    // Let the endpoint handle for HTTPBinding
    }
    return false;
}
Also used : Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) SDDocument(com.sun.xml.ws.api.server.SDDocument) Component(com.sun.xml.ws.api.Component) HTTPBinding(jakarta.xml.ws.http.HTTPBinding)

Example 3 with HTTPBinding

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

the class WSServletDelegate method doPut.

/**
 * Handles HTTP PUT for XML/HTTP binding based endpoints
 * @param request the HTTP request object
 * @param response the HTTP response object
 * @param context the Servlet context object
 * @throws ServletException for errors
 */
public void doPut(HttpServletRequest request, HttpServletResponse response, ServletContext context) throws ServletException {
    // TODO: unify this into doGet.
    try {
        ServletAdapter target = getTarget(request);
        if (target != null) {
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest(WsservletMessages.SERVLET_TRACE_GOT_REQUEST_FOR_ENDPOINT(target.name));
            }
        } else {
            Localizer localizer = getLocalizerFor(request);
            writeNotFoundErrorPage(localizer, response, "Invalid request");
            return;
        }
        Binding binding = target.getEndpoint().getBinding();
        if (binding instanceof HTTPBinding) {
            target.handle(context, request, response);
        } else {
            response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
        }
    } catch (JAXWSExceptionBase e) {
        logger.log(Level.SEVERE, defaultLocalizer.localize(e), e);
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    } catch (Throwable e) {
        if (e instanceof Localizable) {
            logger.log(Level.SEVERE, defaultLocalizer.localize((Localizable) e), e);
        } else {
            logger.log(Level.SEVERE, "caught throwable", e);
        }
        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
Also used : Binding(jakarta.xml.ws.Binding) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) JAXWSExceptionBase(com.sun.xml.ws.util.exception.JAXWSExceptionBase) Localizer(com.sun.istack.localization.Localizer) HTTPBinding(jakarta.xml.ws.http.HTTPBinding) Localizable(com.sun.istack.localization.Localizable)

Aggregations

Binding (jakarta.xml.ws.Binding)3 HTTPBinding (jakarta.xml.ws.http.HTTPBinding)3 Localizable (com.sun.istack.localization.Localizable)1 Localizer (com.sun.istack.localization.Localizer)1 Component (com.sun.xml.ws.api.Component)1 SDDocument (com.sun.xml.ws.api.server.SDDocument)1 JAXWSExceptionBase (com.sun.xml.ws.util.exception.JAXWSExceptionBase)1 WebServiceException (jakarta.xml.ws.WebServiceException)1