Package com.sun.enterprise.webservice

Examples of com.sun.enterprise.webservice.WsUtil


        java.lang.reflect.Constructor cons = svcClass.getConstructor(new Class[]{java.net.URL.class,
                                    javax.xml.namespace.QName.class});
        com.sun.enterprise.webservice.ServiceRefDescUtil descUtil =
           new com.sun.enterprise.webservice.ServiceRefDescUtil();
        descUtil.preServiceCreate(desc);
        WsUtil wsu = new WsUtil();
        URL wsdlFile = wsu.privilegedGetServiceRefWsdl(desc);
        // Check if there is a catalog for this web service client
        // If so resolve the catalog entry
        String genXmlDir;
        if(desc.getBundleDescriptor().getApplication() != null) {
            genXmlDir = desc.getBundleDescriptor().getApplication().getGeneratedXMLDirectory();
           if(!desc.getBundleDescriptor().getApplication().isVirtual()) {
                String subDirName = desc.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
                genXmlDir += (File.separator+subDirName.replaceAll("\\.""_"));
            }
        } else {
            // this is the case of an appclient being run as class file from command line
            genXmlDir = desc.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
        }
        File catalogFile = new File(genXmlDir,
                desc.getBundleDescriptor().getDeploymentDescriptorDir() +
                    File.separator + "jax-ws-catalog.xml");
        if(catalogFile.exists()) {
            wsdlFile = wsu.resolveCatalog(catalogFile, desc.getWsdlFileUri(), null);
        }       
        Object obj =  
           cons.newInstance(wsdlFile, desc.getServiceName());
        descUtil.postServiceCreate();
        return obj;
View Full Code Here


    private Object getClientServiceObject(ServiceReferenceDescriptor desc)
      throws NamingException {

        Class serviceInterfaceClass = null;
        Object returnObj = null;
        WsUtil wsUtil = new WsUtil();

        try {

            WSContainerResolver.set(desc);
           
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
           
            serviceInterfaceClass = cl.loadClass(desc.getServiceInterface());

            resolvePortComponentLinks(desc);

            Service serviceDelegate = null;
            javax.xml.ws.Service jaxwsDelegate = null;
            Object injValue = null;

            if( desc.hasGeneratedServiceInterface() || desc.hasWsdlFile() ) {

                String serviceImplName  = desc.getServiceImplClassName();
                if(serviceImplName != null) {
                    Class serviceImplClass  = cl.loadClass(serviceImplName);
                    serviceDelegate = (Service) serviceImplClass.newInstance();
                } else {
                 
                    // The target is probably a post JAXRPC-1.1- based service;
                    // If Service Interface class is set, check if it is indeed a subclass of Service
                    // initiateInstance should not be called if the user has given javax.xml.ws.Service itself
                    // as the interface through DD
                    if(javax.xml.ws.Service.class.isAssignableFrom(serviceInterfaceClass) &&
                        !javax.xml.ws.Service.class.equals(serviceInterfaceClass)) {
                        // OK - the interface class is indeed the generated service class; get an instance
                        injValue = initiateInstance(serviceInterfaceClass, desc);
                    } else {
                        // First try failed; Try to get the Service class type from injected field name
                        // and from there try to get an instance of the service class
                       
                        // I assume the at all inejction target are expecting the SAME service
                        // interface, therefore I take the first one.
                        if (desc.isInjectable()) {
                           
                            InjectionTarget target = desc.getInjectionTargets().iterator().next();
                            Class serviceType = null;
                            if (target.isFieldInjectable()) {
                                java.lang.reflect.Field f = target.getField();
                                if(f == null) {
                                    String fName = target.getFieldName();
                                    Class targetClass = cl.loadClass(target.getClassName());
                                    try {
                                        f = targetClass.getDeclaredField(target.getFieldName());
                                    } catch(java.lang.NoSuchFieldException nsfe) {}// ignoring exception
                                }
                                serviceType = f.getType();
                            }
                            if (target.isMethodInjectable()) {
                                Method m = target.getMethod();
                                if(m == null) {
                                    String mName = target.getMethodName();
                                    Class targetClass = cl.loadClass(target.getClassName());
                                    try {
                                        m = targetClass.getDeclaredMethod(target.getMethodName());
                                    } catch(java.lang.NoSuchMethodException nsfe) {}// ignoring exception
                                }
                                if (m.getParameterTypes().length==1) {
                                    serviceType = m.getParameterTypes()[0];
                                }
                            }
                            if (serviceType!=null){
                                Class loadedSvcClass = cl.loadClass(serviceType.getCanonicalName());
                                injValue = initiateInstance(loadedSvcClass, desc);
                            }
                        }
                    }
                    // Unable to get hold of generated service class -> try the Service.create avenue to get a Service
                    if(injValue == null) {
                        // Here create the service with WSDL (overridden wsdl if wsdl-override is present)
                        // so that JAXWS runtime uses this wsdl @ runtime
                        javax.xml.ws.Service svc =
                            javax.xml.ws.Service.create((new WsUtil()).privilegedGetServiceRefWsdl(desc),
                                desc.getServiceName());
                        jaxwsDelegate = new JAXWSServiceDelegate(desc, svc, cl);
                    }
                }
                   
                if( desc.hasHandlers() ) {
                    // We need the service's ports to configure the
                    // handler chain (since service-ref handler chain can
                    // optionally specify handler-port association)
                    // so create a configured service and call getPorts
                    Service configuredService =
                        wsUtil.createConfiguredService(desc);
                    Iterator ports = configuredService.getPorts();
                    wsUtil.configureHandlerChain
                        (desc, serviceDelegate, ports, cl);
                }
               
                // check if this is a post 1.1 web service
                if(javax.xml.ws.Service.class.isAssignableFrom(serviceInterfaceClass)) {
                    // This is a JAXWS based webservice client;
        // process handlers and mtom setting
        // moved test for handlers into wsUtil, in case
        // we have to add system handler

        javax.xml.ws.Service service =
      (injValue != null ?
       (javax.xml.ws.Service) injValue : jaxwsDelegate);

        if (service != null) {
                        // Now configure client side handlers
      wsUtil.configureJAXWSClientHandlers(service, desc);
        }
                    // the requested resource is not the service but one of its port.
                    if (injValue!=null && desc.getInjectionTargetType()!=null) {
                        Class requestedPortType = service.getClass().getClassLoader().loadClass(desc.getInjectionTargetType());
                        injValue = service.getPort(requestedPortType);
View Full Code Here

        BundleDescriptor bundledesc = endpoint.getBundleDescriptor();
        ClassLoader cl = bundledesc.getClassLoader();
        // set the app classloader to be used while creating the WSEndpoint
        ClassLoader origCl = Utility.setContextClassLoader(cl);
        try {
            WsUtil wsu = new WsUtil();
            Class serviceEndpointClass =
                    Class.forName(endpoint.getServletImplClass(), true, cl);
            // Get the proper binding using BindingID
            String givenBinding = endpoint.getProtocolBinding();

            // Get list of all wsdls and schema
            SDDocumentSource primaryWsdl = null;
            Collection docs = null;
            if(endpoint.getWebService().hasWsdlFile()) {
                BaseManager mgr;
                if(bundledesc.getApplication().isVirtual()) {
                    mgr = DeploymentServiceUtils.getInstanceManager(DeployableObjectType.WEB);
                } else {
                    mgr = DeploymentServiceUtils.getInstanceManager(DeployableObjectType.APP);
                }
                String deployedDir =
                    mgr.getLocation(bundledesc.getApplication().getRegistrationName());
                File pkgedWsdl;
                if(deployedDir != null) {
                    if(bundledesc.getApplication().isVirtual()) {
                        pkgedWsdl = new File(deployedDir+File.separator+
                                    endpoint.getWebService().getWsdlFileUri());
                    } else {
                        pkgedWsdl = new File(deployedDir+File.separator+
                                bundledesc.getModuleDescriptor().getArchiveUri().replaceAll("\\.", "_") +
                                File.separator + endpoint.getWebService().getWsdlFileUri());
                    }
                } else {
                    pkgedWsdl = new File(endpoint.getWebService().getWsdlFileUrl().getFile());
                }
                if(pkgedWsdl.exists()) {
                    primaryWsdl = SDDocumentSource.create(pkgedWsdl.toURL());
                    docs = wsu.getWsdlsAndSchemas(pkgedWsdl);
                }
            }

            // Get catalog info
            java.net.URL catalogURL = null;
            File catalogFile = new File(bundledesc.getDeploymentDescriptorDir() +
                    File.separator + "jax-ws-catalog.xml");
            if(catalogFile.exists()) {
                catalogURL = catalogFile.toURL();
            }

            // Create Binding and set service side handlers on this binding
//            MTOMFeature mtom = new MTOMFeature(wsu.setMtom(endpoint));
            WSBinding binding = BindingID.parse(givenBinding).createBinding();
            wsu.configureJAXWSServiceHandlers(endpoint, givenBinding, binding);

            WSEndpoint wsep = WSEndpoint.create(
                    serviceEndpointClass, // The endpoint class
                    false, // we do not want JAXWS to process @HandlerChain
                    null, // the invoker interface
View Full Code Here

        }
       
        // Generate final wsdls for all web services and store them in
        // the application repository directory.
        for(Iterator<WebService> iter = webServices.iterator(); iter.hasNext(); ) {
            WsUtil wsUtil = new WsUtil();
            WebService next = iter.next();
           
            // Endpoint with HTTP bindings need not have WSDLs; In which case
            // there is no need for WSDL publishing
            if( (next.getWsdlFileUrl() == null) &&
                 (next.getMappingFileUri() == null) ) {
                for(WebServiceEndpoint wsep : next.getEndpoints()) {
                    /*if(!(HTTPBinding.HTTP_BINDING.equals(wsep.getProtocolBinding()))) {
                        throw new Exception(
                            localStrings.getStringWithDefault(
                            "enterprise.webservice.noWsdlError",
                            "Service {0} has an endpoint with non-HTTP binding but there is no WSDL; Deployment cannot proceed",
                            new Object[] {next.getName()}));                  
                    }*/
                    wsep.composeFinalWsdlUrl(wsUtil.getWebServerInfo(request).getWebServerRootURL(wsep.isSecure()));
                }
                continue;
            }

            URL clientPublishLocation = next.getClientPublishUrl();

            // Even if deployer specified a wsdl file
            // publish location, server can't assume it can access that
            // file system.  Plus, it's cleaner to depend on a file stored
            // within the application repository rather than one directly
            // exposed to the deployer. Name of final wsdl is derived based
            // on the location of its associated module.  This prevents us
            // from having write the module to disk in order to store the
            // modified runtime info.
            URL url = next.getWsdlFileUrl();
           
            // Create the generated WSDL in the generated directory; for that create the directories first
            File genXmlDir = request.getGeneratedXMLDirectory();
            if(request.isApplication()) {
                // Add module name to the generated xml dir for apps
                String subDirName = next.getBundleDescriptor().getModuleDescriptor().getArchiveUri();
                genXmlDir = new File(genXmlDir, subDirName.replaceAll("\\.", "_"));
            }
            File genWsdlFile = null;
           
            if (!next.hasWsdlFile()) {               
                // no wsdl file was specified at deployment or it was an http location
                // we must have downloaded it or created one when
                // deploying into the generated directory directly. pick it up from there,
                // but generate it into a temp
                genWsdlFile = new File(url.toURI());
                genWsdlFile = File.createTempFile("gen_","", genWsdlFile.getParentFile());
            } else {
                String wsdlFileDir = next.getWsdlFileUri().substring(0, next.getWsdlFileUri().lastIndexOf('/'));
                (new File(genXmlDir, wsdlFileDir)).mkdirs();
                genWsdlFile = new File(genXmlDir, next.getWsdlFileUri());
            }
            wsUtil.generateFinalWsdl(url, next, wsUtil.getWebServerInfo(request), genWsdlFile);
           
            if (!next.hasWsdlFile()) {
                // Two renaming operations followed by a delete
                // are required because, on windows, a File.delete and
                // a File.renameTo are not foolproof
View Full Code Here

                        throw new GeneratorException(localStrings.getLocalString(
             "enterprise.webservice.componentlinkunresolved",
                           "The port-component-link {0} cannot be resolved",
                           new Object[] {portInfo.getPortComponentLinkName()}));
                    }
                    WsUtil wsUtil = new WsUtil();
                    WebServerInfo wsi = wsUtil.getWebServerInfo(context.getDeploymentRequest());
                    URL rootURL = wsi.getWebServerRootURL(linkedPortComponent.isSecure());
                    URL actualAddress = linkedPortComponent.composeEndpointAddress(rootURL);
                    if(jaxwsClient) {
                        portInfo.addStubProperty(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                actualAddress.toExternalForm());
View Full Code Here

     */
    public void accept(WebService webService) {
        super.accept(webService);
        try {
             if("1.1".compareTo(webService.getWebServicesDescriptor().getSpecVersion())<0) {
                WsUtil wsUtil = new WsUtil();
                Collection<WebServiceEndpoint> endpoints = webService.getEndpoints();
                for(WebServiceEndpoint ep : endpoints) {
                    if( ep.implementedByWebComponent() ) {
                        wsUtil.updateServletEndpointRuntime(ep);
                    } else {
                        wsUtil.validateEjbEndpoint(ep);
                    }
                }
                //wsImport(webService,  files);
             } else {
                jaxrpcWebService(webService, files);
View Full Code Here

        modelInfo.setLocation(wsdlFile.toExternalForm());

        // Service endpoint interface is required.  Parse generated
        // service interface for it since we can't count on SEI
        // having been listed in standard deployment information.
        WsUtil wsUtil = new WsUtil();
        String serviceInterfaceName = serviceRef.getServiceInterface();
       
        ClassLoader cl = context.getDescriptor().getClassLoader();
        if (cl instanceof EJBClassLoader) {
            List moduleList = EJBClassPathUtils.getApplicationClassPath((Application) context.getDescriptor(), context.getSrcDir().getAbsolutePath());
            for (Iterator itr=moduleList.iterator();itr.hasNext();) {               
                ((EJBClassLoader) cl).appendURL((new File((String) itr.next())));
            }
        }
       
        Class serviceInterface = cl.loadClass(serviceInterfaceName);
        Collection seis = wsUtil.getSEIsFromGeneratedService(serviceInterface);

        if( seis.size() == 0 ) {
            throw new GeneratorException("Invalid Generated Service Interface "
                                         + serviceInterfaceName + " . ");
        } else if( seis.size() > 1 ) {
View Full Code Here

TOP

Related Classes of com.sun.enterprise.webservice.WsUtil

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.