Search in sources :

Example 1 with JavaWsdlMapping

use of org.apache.openejb.jee.JavaWsdlMapping in project tomee by apache.

the class DeploymentLoader method addWebservices.

private static void addWebservices(final WsModule wsModule) throws OpenEJBException {
    final boolean webservicesEnabled = SystemInstance.get().getOptions().get(ConfigurationFactory.WEBSERVICES_ENABLED, true);
    if (!webservicesEnabled) {
        wsModule.getAltDDs().remove("webservices.xml");
        // should be null already, but just for good measure
        wsModule.setWebservices(null);
        return;
    }
    // get location of webservices.xml file
    final Object webservicesObject = wsModule.getAltDDs().get("webservices.xml");
    if (webservicesObject == null || !(webservicesObject instanceof URL)) {
        return;
    }
    final URL webservicesUrl = (URL) webservicesObject;
    // determine the base url for this module (either file: or jar:)
    URL moduleUrl;
    try {
        final File jarFile = new File(wsModule.getJarLocation());
        moduleUrl = jarFile.toURI().toURL();
        if (jarFile.isFile()) {
            moduleUrl = new URL("jar", "", -1, moduleUrl + "!/");
        }
    } catch (final MalformedURLException e) {
        logger.warning("Invalid module location " + wsModule.getJarLocation());
        return;
    }
    // parse the webservices.xml file
    final Map<URL, JavaWsdlMapping> jaxrpcMappingCache = new HashMap<URL, JavaWsdlMapping>();
    final Webservices webservices = ReadDescriptors.readWebservices(webservicesUrl);
    wsModule.setWebservices(webservices);
    if ("file".equals(webservicesUrl.getProtocol())) {
        wsModule.getWatchedResources().add(URLs.toFilePath(webservicesUrl));
    }
    // parse any jaxrpc-mapping-files mentioned in the webservices.xml file
    for (final WebserviceDescription webserviceDescription : webservices.getWebserviceDescription()) {
        final String jaxrpcMappingFile = webserviceDescription.getJaxrpcMappingFile();
        if (jaxrpcMappingFile != null) {
            final URL jaxrpcMappingUrl;
            try {
                jaxrpcMappingUrl = new URL(moduleUrl, jaxrpcMappingFile);
                JavaWsdlMapping jaxrpcMapping = jaxrpcMappingCache.get(jaxrpcMappingUrl);
                if (jaxrpcMapping == null) {
                    jaxrpcMapping = ReadDescriptors.readJaxrpcMapping(jaxrpcMappingUrl);
                    jaxrpcMappingCache.put(jaxrpcMappingUrl, jaxrpcMapping);
                }
                webserviceDescription.setJaxrpcMapping(jaxrpcMapping);
                if ("file".equals(jaxrpcMappingUrl.getProtocol())) {
                    wsModule.getWatchedResources().add(URLs.toFilePath(jaxrpcMappingUrl));
                }
            } catch (final MalformedURLException e) {
                logger.warning("Invalid jaxrpc-mapping-file location " + jaxrpcMappingFile);
            }
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) WebserviceDescription(org.apache.openejb.jee.WebserviceDescription) JavaWsdlMapping(org.apache.openejb.jee.JavaWsdlMapping) Webservices(org.apache.openejb.jee.Webservices) JarFile(java.util.jar.JarFile) File(java.io.File) URL(java.net.URL)

Example 2 with JavaWsdlMapping

use of org.apache.openejb.jee.JavaWsdlMapping in project tomee by apache.

the class AxisService method getJaxRpcServiceInfo.

private JaxRpcServiceInfo getJaxRpcServiceInfo(ClassLoader classLoader) throws OpenEJBException {
    // the java to wsdl mapping file
    JavaWsdlMapping mapping = null;
    // the schema data from the wsdl file
    CommonsSchemaInfoBuilder xmlBeansSchemaInfoBuilder = new CommonsSchemaInfoBuilder(null, null);
    // webservice.xml declaration of this service
    PortComponent portComponent = null;
    // wsdl.xml declaration of this service
    Port port = null;
    String wsdlFile = null;
    XmlSchemaInfo schemaInfo = xmlBeansSchemaInfoBuilder.createSchemaInfo();
    JaxRpcServiceInfoBuilder serviceInfoBuilder = new JaxRpcServiceInfoBuilder(mapping, schemaInfo, portComponent, port, wsdlFile, classLoader);
    JaxRpcServiceInfo serviceInfo = serviceInfoBuilder.createServiceInfo();
    return serviceInfo;
}
Also used : JaxRpcServiceInfo(org.apache.openejb.server.axis.assembler.JaxRpcServiceInfo) CommonsSchemaInfoBuilder(org.apache.openejb.server.axis.assembler.CommonsSchemaInfoBuilder) PortComponent(org.apache.openejb.jee.PortComponent) JaxRpcServiceInfoBuilder(org.apache.openejb.server.axis.assembler.JaxRpcServiceInfoBuilder) Port(javax.wsdl.Port) JavaWsdlMapping(org.apache.openejb.jee.JavaWsdlMapping) XmlSchemaInfo(org.apache.openejb.server.axis.assembler.XmlSchemaInfo)

Aggregations

JavaWsdlMapping (org.apache.openejb.jee.JavaWsdlMapping)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 JarFile (java.util.jar.JarFile)1 Port (javax.wsdl.Port)1 PortComponent (org.apache.openejb.jee.PortComponent)1 WebserviceDescription (org.apache.openejb.jee.WebserviceDescription)1 Webservices (org.apache.openejb.jee.Webservices)1 CommonsSchemaInfoBuilder (org.apache.openejb.server.axis.assembler.CommonsSchemaInfoBuilder)1 JaxRpcServiceInfo (org.apache.openejb.server.axis.assembler.JaxRpcServiceInfo)1 JaxRpcServiceInfoBuilder (org.apache.openejb.server.axis.assembler.JaxRpcServiceInfoBuilder)1 XmlSchemaInfo (org.apache.openejb.server.axis.assembler.XmlSchemaInfo)1