Search in sources :

Example 26 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 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)

Example 27 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) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 28 with Binding

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

the class HandlerClient method testSOAP12Binding1.

/*
     * The normal tests in this file are for soap 1.1. This is a soap 1.2
     * test to make sure that the port is created with the proper binding
     * so that the proper handlers are called. See bug 6353179.
     *
     * Not working right now -- can't get endpoint to work.
     */
public void testSOAP12Binding1() throws Exception {
    Hello_Service service = createService();
    Hello12 stub = create12Stub(service);
    // make sure port is working
    int x = 1;
    // server handler only
    int diff = 2;
    int y = stub.hello12(x);
    assertEquals(x + diff, y);
    Binding binding = ((BindingProvider) stub).getBinding();
    List<Handler> handlers = binding.getHandlerChain();
    assertEquals("should be 1 handler in chain", 1, handlers.size());
    Handler handler = handlers.get(0);
    assertTrue("handler should be type Port12Handler, not " + handler.getClass().toString(), handler instanceof Port12Handler);
    Port12Handler p12h = (Port12Handler) handler;
    p12h.resetCalled();
    stub.hello12(2);
    assertEquals("handler should have been called two times", 2, p12h.getCalled());
}
Also used : Binding(jakarta.xml.ws.Binding) SOAPTestHandler(fromwsdl.handler_simple.common.SOAPTestHandler) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 29 with Binding

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

the class HandlerChainTester method testHandlersOnTestPort.

public void testHandlersOnTestPort() {
    TestService_Service service = getService();
    TestService testStub = service.getTestServicePort();
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    List<Handler> chain = testBinding.getHandlerChain();
    // System.out.println(chain.size());
    assertEquals(3, chain.size());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

Example 30 with Binding

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

the class HandlerChainTester method testHandlersOnReportPort1.

public void testHandlersOnReportPort1() {
    Service service = Service.create(WSDL_LOCATION, TESTSERVICE);
    ReportService testStub = service.getPort(ReportService.class);
    Binding testBinding = ((BindingProvider) testStub).getBinding();
    List<Handler> chain = testBinding.getHandlerChain();
    // System.out.println(chain.size());
    assertEquals(0, chain.size());
}
Also used : SOAPBinding(jakarta.xml.ws.soap.SOAPBinding) Binding(jakarta.xml.ws.Binding) Service(jakarta.xml.ws.Service) Handler(jakarta.xml.ws.handler.Handler) BindingProvider(jakarta.xml.ws.BindingProvider)

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