Search in sources :

Example 61 with WebServiceException

use of javax.xml.ws.WebServiceException in project Payara by payara.

the class ServletWebServiceDelegate method postInit.

@Override
public void postInit(ServletConfig servletConfig) throws ServletException {
    String servletName = "unknown";
    try {
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
        JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
        WebBundleDescriptor webBundle = null;
        if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
            webBundle = ((WebBundleDescriptor) jndiNameEnv);
        } else {
            throw new WebServiceException("Cannot intialize the JAXRPCServlet for " + jndiNameEnv);
        }
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        servletName = servletConfig.getServletName();
        WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
        if (webComponent != null) {
            WebServicesDescriptor webServices = webBundle.getWebServices();
            Collection endpoints = webServices.getEndpointsImplementedBy(webComponent);
            // Only 1 endpoint per servlet is supported, even though
            // data structure implies otherwise.
            endpoint_ = (WebServiceEndpoint) endpoints.iterator().next();
            registerEndpoint(classLoader);
            // security
            if (secServ != null) {
                SystemHandlerDelegate securityHandlerDelegate = secServ.getSecurityHandler(endpoint_);
                if (securityHandlerDelegate != null) {
                    rpcDelegate_.setSystemHandlerDelegate(securityHandlerDelegate);
                    // need to invoke the endpoint lifecylcle
                    endpointImpl_ = JAXRPCEndpointImpl.class.cast(wsEngine_.createHandler(securityHandlerDelegate, endpoint_));
                    rpcDelegate_.setSystemHandlerDelegate(endpointImpl_);
                }
            }
        } else {
            throw new ServletException(servletName + " not found");
        }
    } catch (Throwable t) {
        String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
        logger.log(Level.WARNING, msg, t);
        throw new ServletException(t);
    }
}
Also used : WebServicesDescriptor(com.sun.enterprise.deployment.WebServicesDescriptor) WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) SystemHandlerDelegate(com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate) WebComponentDescriptor(com.sun.enterprise.deployment.WebComponentDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) JAXRPCEndpointImpl(org.glassfish.webservices.monitoring.JAXRPCEndpointImpl)

Example 62 with WebServiceException

use of javax.xml.ws.WebServiceException in project Payara by payara.

the class WSServletContextListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
    ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
    JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
    WebBundleDescriptor webBundle = null;
    if (jndiNameEnv != null && jndiNameEnv instanceof BundleDescriptor && ((BundleDescriptor) jndiNameEnv).getModuleType().equals(DOLUtils.warType())) {
        webBundle = ((WebBundleDescriptor) jndiNameEnv);
    } else {
        throw new WebServiceException("Cannot intialize the JAXWSServlet for " + jndiNameEnv);
    }
    contextRoot = webBundle.getContextRoot();
    WebServicesDescriptor webServices = webBundle.getWebServices();
    try {
        for (WebServiceEndpoint endpoint : webServices.getEndpoints()) {
            registerEndpoint(endpoint, sce.getServletContext());
        }
    } catch (Throwable t) {
        // TODO Fix Rama
        logger.log(Level.WARNING, LogUtils.DEPLOYMENT_FAILED, t);
        sce.getServletContext().removeAttribute("ADAPTER_LIST");
        throw new RuntimeException("Servlet web service endpoint '" + "' failure", t);
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager)

Example 63 with WebServiceException

use of javax.xml.ws.WebServiceException in project Payara by payara.

the class WebServiceEjbEndpointRegistry method registerEndpoint.

@Override
public void registerEndpoint(WebServiceEndpoint webserviceEndpoint, EjbEndpointFacade ejbContainer, Object servant, Class tieClass) {
    String uri = null;
    EjbRuntimeEndpointInfo endpoint = createEjbEndpointInfo(webserviceEndpoint, ejbContainer, servant, tieClass);
    synchronized (webServiceEjbEndpoints) {
        String uriRaw = endpoint.getEndpointAddressUri();
        if (uriRaw != null) {
            uri = (uriRaw.charAt(0) == '/') ? uriRaw.substring(1) : uriRaw;
            if (webServiceEjbEndpoints.containsKey(uri)) {
                logger.log(Level.SEVERE, LogUtils.ENTERPRISE_WEBSERVICE_DUPLICATE_SERVICE, uri);
            }
            webServiceEjbEndpoints.put(uri, endpoint);
            regenerateEjbContextRoots();
            if (adapterListMap.get(uri) == null) {
                ServletAdapterList list = new ServletAdapterList();
                adapterListMap.put(uri, list);
            }
        } else
            throw new WebServiceException(logger.getResourceBundle().getString(LogUtils.EJB_ENDPOINTURI_ERROR));
    }
    // notify monitoring layers that a new endpoint is being created.
    WebServiceEngineImpl engine = WebServiceEngineImpl.getInstance();
    if (hasMappingFileUri(endpoint.getEndpoint())) {
        engine.createHandler((com.sun.xml.rpc.spi.runtime.SystemHandlerDelegate) null, endpoint.getEndpoint());
    } else {
        engine.createHandler(endpoint.getEndpoint());
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ServletAdapterList(com.sun.xml.ws.transport.http.servlet.ServletAdapterList) WebServiceEngineImpl(org.glassfish.webservices.monitoring.WebServiceEngineImpl)

Example 64 with WebServiceException

use of javax.xml.ws.WebServiceException in project Payara by payara.

the class WebServiceReferenceManagerImpl method getWebServiceFeatureBean.

private WebServiceFeature getWebServiceFeatureBean(Annotation a) {
    WebServiceFeatureAnnotation wsfa = a.annotationType().getAnnotation(WebServiceFeatureAnnotation.class);
    Class<? extends WebServiceFeature> beanClass = wsfa.bean();
    WebServiceFeature bean;
    Constructor ftrCtr = null;
    String[] paramNames = null;
    for (Constructor con : beanClass.getConstructors()) {
        FeatureConstructor ftrCtrAnn = (FeatureConstructor) con.getAnnotation(FeatureConstructor.class);
        if (ftrCtrAnn != null) {
            if (ftrCtr == null) {
                ftrCtr = con;
                paramNames = ftrCtrAnn.value();
            } else {
                throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_MORETHANONE_FTRCONSTRUCTOR(a, beanClass));
            }
        }
    }
    if (ftrCtr == null) {
        throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_NO_FTRCONSTRUCTOR(a, beanClass));
    }
    if (ftrCtr.getParameterTypes().length != paramNames.length) {
        throw new WebServiceException(ModelerMessages.RUNTIME_MODELER_WSFEATURE_ILLEGAL_FTRCONSTRUCTOR(a, beanClass));
    }
    try {
        Object[] params = new Object[paramNames.length];
        for (int i = 0; i < paramNames.length; i++) {
            Method m = a.annotationType().getDeclaredMethod(paramNames[i]);
            params[i] = m.invoke(a);
        }
        bean = (WebServiceFeature) ftrCtr.newInstance(params);
    } catch (Exception e) {
        throw new WebServiceException(e);
    }
    return bean;
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) FeatureConstructor(com.sun.xml.ws.api.FeatureConstructor) NamingException(javax.naming.NamingException) PrivilegedActionException(java.security.PrivilegedActionException) WebServiceException(javax.xml.ws.WebServiceException) WebServiceFeatureAnnotation(javax.xml.ws.spi.WebServiceFeatureAnnotation) WebServiceFeature(javax.xml.ws.WebServiceFeature)

Example 65 with WebServiceException

use of javax.xml.ws.WebServiceException in project Payara by payara.

the class JAXWSServlet method init.

public void init(ServletConfig servletConfig) throws ServletException {
    String servletName = "unknown";
    try {
        super.init(servletConfig);
        wsEngine_ = WebServiceEngineImpl.getInstance();
        // Register endpoints here
        WebServiceContractImpl wscImpl = WebServiceContractImpl.getInstance();
        ComponentEnvManager compEnvManager = wscImpl.getComponentEnvManager();
        JndiNameEnvironment jndiNameEnv = compEnvManager.getCurrentJndiNameEnvironment();
        WebBundleDescriptor webBundle = null;
        if (jndiNameEnv != null && jndiNameEnv instanceof WebBundleDescriptor) {
            webBundle = ((WebBundleDescriptor) jndiNameEnv);
        } else {
            throw new WebServiceException("Cannot intialize the JAXWSServlet for " + jndiNameEnv);
        }
        servletName = servletConfig.getServletName();
        contextRoot = webBundle.getContextRoot();
        WebComponentDescriptor webComponent = webBundle.getWebComponentByCanonicalName(servletName);
        if (webComponent != null) {
            WebServicesDescriptor webServices = webBundle.getWebServices();
            Collection<WebServiceEndpoint> endpoints = webServices.getEndpointsImplementedBy(webComponent);
            // Only 1 endpoint per servlet is supported, even though
            // data structure implies otherwise.
            endpoint = endpoints.iterator().next();
        } else {
            throw new ServletException(servletName + " not found");
        }
        // need to invoke the endpoint lifecylcle
        if (!(HTTPBinding.HTTP_BINDING.equals(endpoint.getProtocolBinding()))) {
            // Doing this so that restful service are not monitored
            wsEngine_.createHandler(endpoint);
        }
        if (endpoint.getWsdlExposed() != null) {
            wsdlExposed = Boolean.parseBoolean(endpoint.getWsdlExposed());
        }
        // For web components, this will be relative to the web app
        // context root.  Make sure there is a leading slash.
        String uri = endpoint.getEndpointAddressUri();
        urlPattern = uri.startsWith("/") ? uri : "/" + uri;
    } catch (Throwable t) {
        String msg = MessageFormat.format(logger.getResourceBundle().getString(LogUtils.SERVLET_ENDPOINT_FAILURE), servletName);
        logger.log(Level.WARNING, msg, t);
        throw new ServletException(t);
    }
    requestTracing = org.glassfish.internal.api.Globals.getDefaultHabitat().getService(RequestTracingService.class);
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) RequestTracingService(fish.payara.nucleus.requesttracing.RequestTracingService) ServletException(javax.servlet.ServletException)

Aggregations

WebServiceException (javax.xml.ws.WebServiceException)120 Test (org.junit.Test)50 URL (java.net.URL)37 BindingProvider (javax.xml.ws.BindingProvider)25 Service (javax.xml.ws.Service)22 QName (javax.xml.namespace.QName)14 IOException (java.io.IOException)10 Message (org.apache.cxf.common.i18n.Message)9 JAXBException (javax.xml.bind.JAXBException)8 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)8 Bus (org.apache.cxf.Bus)7 Packet (com.sun.xml.ws.api.message.Packet)6 AuthStatus (javax.security.auth.message.AuthStatus)6 SOAPException (javax.xml.soap.SOAPException)6 SOAPMessage (javax.xml.soap.SOAPMessage)6 ArrayList (java.util.ArrayList)5 WebService (javax.jws.WebService)5 Subject (javax.security.auth.Subject)5 HttpSession (javax.servlet.http.HttpSession)5 Handler (javax.xml.ws.handler.Handler)5