Search in sources :

Example 6 with ServletAdapter

use of com.sun.xml.ws.transport.http.servlet.ServletAdapter in project Payara by payara.

the class Ejb3MessageDispatcher method handlePost.

private void handlePost(HttpServletRequest req, HttpServletResponse resp, EjbRuntimeEndpointInfo endpointInfo) throws IOException {
    AdapterInvocationInfo adapterInfo = null;
    ServletAdapter adapter;
    try {
        try {
            adapterInfo = (AdapterInvocationInfo) endpointInfo.prepareInvocation(true);
            adapter = adapterInfo.getAdapter();
            if (adapter != null) {
                adapter.handle(null, req, resp);
            } else {
                logger.log(Level.SEVERE, LogUtils.UNABLE_FIND_ADAPTER, endpointInfo.getEndpoint().getName());
            }
        } finally {
            // Always call release, even if an error happened
            // during getImplementor(), since some of the
            // preInvoke steps might have occurred.  It's ok
            // if implementor is null.
            endpointInfo.releaseImplementor((adapterInfo == null) ? null : adapterInfo.getInv());
        }
    } catch (Throwable e) {
        String errorMessage = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.ERROR_ON_EJB), new Object[] { endpointInfo.getEndpoint().getEndpointName(), endpointInfo.getEndpointAddressUri(), e.getMessage() });
        logger.log(Level.WARNING, errorMessage, e);
        String binding = endpointInfo.getEndpoint().getProtocolBinding();
        WsUtil.raiseException(resp, binding, errorMessage);
    }
}
Also used : ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter)

Example 7 with ServletAdapter

use of com.sun.xml.ws.transport.http.servlet.ServletAdapter in project Payara by payara.

the class Ejb3MessageDispatcher method handleGet.

private void handleGet(HttpServletRequest req, HttpServletResponse resp, ServletContext ctxt, EjbRuntimeEndpointInfo endpointInfo) throws IOException {
    AdapterInvocationInfo adapterInfo = null;
    ServletAdapter adapter;
    try {
        adapterInfo = (AdapterInvocationInfo) endpointInfo.prepareInvocation(true);
        adapter = adapterInfo.getAdapter();
        if (adapter != null) {
            adapter.publishWSDL(ctxt, req, resp);
        } else {
            String message = "Invalid wsdl request " + req.getRequestURL();
            (new WsUtil()).writeInvalidMethodType(resp, message);
        }
    } catch (Throwable e) {
        String errorMessage = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.ERROR_ON_EJB), new Object[] { endpointInfo.getEndpoint().getEndpointName(), endpointInfo.getEndpointAddressUri(), e.getMessage() });
        logger.log(Level.WARNING, errorMessage, e);
        String binding = endpointInfo.getEndpoint().getProtocolBinding();
        WsUtil.raiseException(resp, binding, errorMessage);
    } finally {
        endpointInfo.releaseImplementor((adapterInfo == null) ? null : adapterInfo.getInv());
    }
}
Also used : ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter)

Example 8 with ServletAdapter

use of com.sun.xml.ws.transport.http.servlet.ServletAdapter in project Payara by payara.

the class JAXWSServlet method doGet.

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) {
        Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath());
        if ((endpt != null) && ((endpt.getDescriptor().isSecure()) || (endpt.getDescriptor().getMessageSecurityBinding() != null) || endpoint.hasSecurePipeline())) {
            String message = endpt.getDescriptor().getWebService().getName() + "is a secured web service; Tester feature is not supported for secured services";
            (new WsUtil()).writeInvalidMethodType(response, message);
            return;
        }
        if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
            WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
            return;
        }
    }
    if (!("WSDL".equalsIgnoreCase(request.getQueryString())) && (HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding()))) {
        doPost(request, response);
        return;
    }
    // normal WSDL retrieval invocation
    try {
        ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request);
        if (targetEndpoint != null && wsdlExposed) {
            targetEndpoint.publishWSDL(getServletContext(), request, response);
        } else {
            String message = "Invalid wsdl request " + request.getRequestURL();
            (new WsUtil()).writeInvalidMethodType(response, message);
        }
    } catch (Throwable t) {
        ServletException se = new ServletException();
        se.initCause(t);
        throw se;
    }
}
Also used : ServletException(javax.servlet.ServletException) ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter) Endpoint(org.glassfish.webservices.monitoring.Endpoint)

Example 9 with ServletAdapter

use of com.sun.xml.ws.transport.http.servlet.ServletAdapter in project Payara by payara.

the class JAXWSServlet method doPost.

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    startedEvent(endpoint.getEndpointAddressPath());
    if (("Tester".equalsIgnoreCase(request.getQueryString())) && (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding())))) {
        Endpoint endpt = wsEngine_.getEndpoint(request.getServletPath());
        if (endpt != null && Boolean.parseBoolean(endpt.getDescriptor().getDebugging())) {
            WebServiceTesterServlet.invoke(request, response, endpt.getDescriptor());
            endedEvent(endpoint.getEndpointAddressPath());
            return;
        }
    }
    // lookup registered URLs and get the appropriate adapter;
    // pass control to the adapter
    RequestTraceSpan span = null;
    try {
        ServletAdapter targetEndpoint = (ServletAdapter) getEndpointFor(request);
        if (targetEndpoint != null) {
            if (requestTracing.isRequestTracingEnabled()) {
                span = constructWsRequestSpan(request, targetEndpoint.getAddress());
            }
            targetEndpoint.handle(getServletContext(), request, response);
        } else {
            throw new ServletException("Service not found");
        }
    } catch (Throwable t) {
        ServletException se = new ServletException();
        se.initCause(t);
        throw se;
    } finally {
        if (requestTracing.isRequestTracingEnabled() && span != null) {
            requestTracing.traceSpan(span);
        }
    }
    endedEvent(endpoint.getEndpointAddressPath());
}
Also used : ServletException(javax.servlet.ServletException) ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter) Endpoint(org.glassfish.webservices.monitoring.Endpoint) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan)

Example 10 with ServletAdapter

use of com.sun.xml.ws.transport.http.servlet.ServletAdapter in project Payara by payara.

the class WebServiceReferenceManagerImpl method generateWsdlFile.

private URL generateWsdlFile(ServiceReferenceDescriptor desc) throws IOException {
    /*
        * Following piece of code is basically a copy-paste from JAXWSServlet's
        * doGet method (line 230) and from com.sun.xml.ws.transport.http.servlet.HttpAdapter's
        * publishWSDL method (line 587).This piece of code is not completely clear to me,
        * what I have understood so far is, during WSEndPoint creation on line 267 in
        * WSServletContextListener, com.sun.xml.ws.server.EndPointFactory.create (line 116)
        * method is invoked where ServiceDocumentImpl instance is created, which is later
        * being fetched here to generate wsdl. When serviceDefinition.getPrimary() is
        * invoked, basically it returns the reference to wsdl document marked as primary
        * wsdl inside ServiceDefinition. Probably we can directly fetch this wsdl
        * but for now I will go with the way it has been implemented in HttpAdapter.
        */
    File optionalWsdl = getOptionalWsdlLocation(desc);
    if (optionalWsdl.exists())
        return optionalWsdl.toURI().toURL();
    createParentDirs(optionalWsdl);
    ServletAdapter targetEndpoint = getServletAdapter(desc);
    if (targetEndpoint == null)
        return null;
    ServiceDefinition serviceDefinition = targetEndpoint.getServiceDefinition();
    Iterator wsdlnum = serviceDefinition.iterator();
    SDDocument wsdlDocument = null;
    while (wsdlnum.hasNext()) {
        SDDocument xsdnum = (SDDocument) wsdlnum.next();
        if (xsdnum == serviceDefinition.getPrimary()) {
            wsdlDocument = xsdnum;
            break;
        }
    }
    if (wsdlDocument == null)
        return null;
    OutputStream outputStream = null;
    try {
        outputStream = new BufferedOutputStream(new FileOutputStream(optionalWsdl));
        PortAddressResolver portAddressResolver = targetEndpoint.getPortAddressResolver(getBaseAddress(desc.getWsdlFileUrl()));
        DocumentAddressResolver resolver = targetEndpoint.getDocumentAddressResolver(portAddressResolver);
        wsdlDocument.writeTo(portAddressResolver, resolver, outputStream);
    } finally {
        if (outputStream != null)
            outputStream.close();
    }
    return optionalWsdl.toURI().toURL();
}
Also used : ServletAdapter(com.sun.xml.ws.transport.http.servlet.ServletAdapter) Iterator(java.util.Iterator)

Aggregations

ServletAdapter (com.sun.xml.ws.transport.http.servlet.ServletAdapter)10 ServletAdapterList (com.sun.xml.ws.transport.http.servlet.ServletAdapterList)3 InjectionException (com.sun.enterprise.container.common.spi.util.InjectionException)2 InjectionManager (com.sun.enterprise.container.common.spi.util.InjectionManager)2 URL (java.net.URL)2 ServletException (javax.servlet.ServletException)2 Handler (javax.xml.ws.handler.Handler)2 Endpoint (org.glassfish.webservices.monitoring.Endpoint)2 ReliabilityConfig (com.sun.enterprise.deployment.runtime.ws.ReliabilityConfig)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 SchemaValidationFeature (com.sun.xml.ws.developer.SchemaValidationFeature)1 StreamingAttachmentFeature (com.sun.xml.ws.developer.StreamingAttachmentFeature)1 ReliableMessagingFeatureBuilder (com.sun.xml.ws.rx.rm.api.ReliableMessagingFeatureBuilder)1 RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 ServletContext (javax.servlet.ServletContext)1 RespectBindingFeature (javax.xml.ws.RespectBindingFeature)1