Search in sources :

Example 1 with Binding

use of jakarta.xml.ws.Binding 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 Binding

use of jakarta.xml.ws.Binding 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 Binding

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

the class HandlerClient method testLogicalGetSourceOnly.

/*
     * Test removes the static handler and adds a logical
     * handler that uses JAXB to change the message.
     */
// public void testLogicalJAXB() throws Exception {
// Hello stub = createStub();
// Binding binding = ((BindingProvider) stub).getBinding();
// 
// LogicalTestHandler handler = new LogicalTestHandler();
// handler.setHandleMode(LogicalTestHandler.HandleMode.JAXB);
// List<Handler> handlerChain = new ArrayList<Handler>();
// handlerChain.add(handler);
// binding.setHandlerChain(handlerChain);
// 
// 
// int x = 1;
// int diff = 4; // 2 per handler invoked
// 
// int y = stub.hello(x);
// assertEquals(x+diff, y); // x+4 with all handlers
// }
/*
     * Test removes the static handler and adds a logical
     * handler that gets the source but does not change it.
     */
public void testLogicalGetSourceOnly() throws Exception {
    Hello stub = createStub();
    Binding binding = ((BindingProvider) stub).getBinding();
    LogicalTestHandler handler = new LogicalTestHandler();
    handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE_NO_CHANGE);
    List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(handler);
    binding.setHandlerChain(handlerChain);
    int x = 1;
    // 2 per handler invoked
    int diff = 2;
    int y = stub.hello(x);
    assertEquals(x + diff, y);
}
Also used : Binding(jakarta.xml.ws.Binding) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 4 with Binding

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

the class HandlerClient method testLogicalSource.

/*
     * Test removes the static handler and adds a logical
     * handler that uses a Source to change the message.
     */
public void testLogicalSource() throws Exception {
    Hello stub = createStub();
    Binding binding = ((BindingProvider) stub).getBinding();
    LogicalTestHandler handler = new LogicalTestHandler();
    handler.setHandleMode(LogicalTestHandler.HandleMode.SOURCE);
    List<Handler> handlerChain = new ArrayList<Handler>();
    handlerChain.add(handler);
    binding.setHandlerChain(handlerChain);
    int x = 1;
    // 2 per handler invoked
    int diff = 4;
    int y = stub.hello(x);
    // x+4 with all handlers
    assertEquals(x + diff, y);
}
Also used : Binding(jakarta.xml.ws.Binding) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 5 with Binding

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

the class HandlerClient method testDynamic1.

/*
     * Test tries to add a handler programmatically after clearing
     * handlers out of the service. Adds handler to binding. Uses
     * an empty handler resolver for clearing the service.
     */
public void testDynamic1() throws Exception {
    Hello_Service service = createService();
    service.setHandlerResolver(new HandlerResolver() {

        public List<Handler> getHandlerChain(PortInfo info) {
            return new ArrayList<Handler>();
        }
    });
    Hello stub = createStub(service);
    int x = 1;
    // 2 per handler invoked
    int diff = 2;
    int y = stub.hello(x);
    assertTrue(y == x + diff);
    // now add client handler
    List<Handler> handlerList = new ArrayList<Handler>();
    handlerList.add(new SOAPTestHandler());
    Binding binding = ((BindingProvider) stub).getBinding();
    binding.setHandlerChain(handlerList);
    // test again
    diff = 4;
    y = stub.hello(x);
    assertTrue(y == x + diff);
}
Also used : Binding(jakarta.xml.ws.Binding) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) ArrayList(java.util.ArrayList) Handler(jakarta.xml.ws.handler.Handler) SOAPTestHandler(fromwsdl.handler_simple_rpclit.common.SOAPTestHandler) BindingProvider(jakarta.xml.ws.BindingProvider) PortInfo(jakarta.xml.ws.handler.PortInfo) HandlerResolver(jakarta.xml.ws.handler.HandlerResolver) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Binding (jakarta.xml.ws.Binding)37 BindingProvider (jakarta.xml.ws.BindingProvider)32 Handler (jakarta.xml.ws.handler.Handler)30 SOAPBinding (jakarta.xml.ws.soap.SOAPBinding)17 ArrayList (java.util.ArrayList)8 SOAPTestHandler (fromwsdl.handler_simple.common.SOAPTestHandler)5 Service (jakarta.xml.ws.Service)5 WebServiceException (jakarta.xml.ws.WebServiceException)5 SOAPTestHandler (fromwsdl.handler_simple_rpclit.common.SOAPTestHandler)4 HTTPBinding (jakarta.xml.ws.http.HTTPBinding)4 Source (javax.xml.transform.Source)3 BaseSOAPHandler (fromwsdl.handler.common.BaseSOAPHandler)2 BaseSOAPHandler (handler.handler_processing.common.BaseSOAPHandler)2 ProtocolException (jakarta.xml.ws.ProtocolException)2 HandlerResolver (jakarta.xml.ws.handler.HandlerResolver)2 PortInfo (jakarta.xml.ws.handler.PortInfo)2 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Localizable (com.sun.istack.localization.Localizable)1