You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ba...@apache.org on 2006/12/08 16:27:02 UTC
svn commit: r484636 - in
/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws:
description/builder/ description/impl/ util/
Author: barrettj
Date: Fri Dec 8 07:27:01 2006
New Revision: 484636
URL: http://svn.apache.org/viewvc?view=rev&rev=484636
Log:
AXIS2-1845
Submitted by Roy Wood Jr; Addresses some issues with class loading and wsdl importing in the DBC.
Added:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/builder/ParameterDescriptionComposite.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/builder/ParameterDescriptionComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/builder/ParameterDescriptionComposite.java?view=diff&rev=484636&r1=484635&r2=484636
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/builder/ParameterDescriptionComposite.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/builder/ParameterDescriptionComposite.java Fri Dec 8 07:27:01 2006
@@ -54,7 +54,12 @@
public Class getParameterTypeClass() {
ClassLoader classLoader = null;
- // classLoader = getMethodDescriptionCompositeRef().getDescriptionBuilderCompositeRef().getClassLoader();
+
+ if (getMethodDescriptionCompositeRef() != null) {
+ if (getMethodDescriptionCompositeRef().getDescriptionBuilderCompositeRef() != null){
+ classLoader = getMethodDescriptionCompositeRef().getDescriptionBuilderCompositeRef().getClassLoader();
+ }
+ }
if (parameterTypeClass == null) {
if (getParameterType() != null) {
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=484636&r1=484635&r2=484636
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Fri Dec 8 07:27:01 2006
@@ -16,6 +16,7 @@
*/
package org.apache.axis2.jaxws.description.impl;
+import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -61,7 +62,6 @@
import org.apache.axis2.jaxws.description.builder.WsdlComposite;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.util.WSDL4JWrapper;
-import org.apache.axis2.jaxws.util.WSDLWrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
@@ -679,10 +679,18 @@
// TODO: Change this to use WSDLToAxisServiceBuilder superclass
// Note that the axis service builder takes only the localpart of the port qname.
// TODO:: This should check that the namespace of the definition matches the namespace of the portQName per JAXRPC spec
+
WSDL11ToAxisServiceBuilder serviceBuilder =
new WSDL11ToAxisServiceBuilder( getServiceDescriptionImpl().getWSDLWrapper().getDefinition(),
getServiceDescription().getServiceQName(),
getPortQName().getLocalPart());
+
+ if (getServiceDescriptionImpl().isDBCMap()) {
+ //this.class.getClass().getClassLoader();
+ URIResolverImpl uriResolver =
+ new URIResolverImpl(composite.getClassLoader());
+ serviceBuilder.setCustomResolver(uriResolver);
+ }
// TODO: Currently this only builds the client-side AxisService;
// it needs to do client and server somehow.
Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java?view=auto&rev=484636
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/URIResolverImpl.java Fri Dec 8 07:27:01 2006
@@ -0,0 +1,163 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.description.impl;
+
+import java.io.File;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.xml.sax.InputSource;
+
+/**
+ * This class is used to locate xml schemas that are imported by wsdl documents.
+ *
+ */
+public class URIResolverImpl implements URIResolver {
+
+ private ClassLoader classLoader;
+
+ public URIResolverImpl() {
+ }
+
+ public URIResolverImpl(ClassLoader cl) {
+ classLoader = cl;
+ }
+
+ public InputSource resolveEntity(String namespace, String schemaLocation,
+ String baseUri) {
+
+ InputStream is = null;
+ URI pathURI = null;
+ if (baseUri != null) {
+ try {
+ // if the location is an absolute path, build a URL directly
+ // from it
+ if (isAbsolute(schemaLocation)) {
+ is = getInputStreamForURI(schemaLocation);
+ }
+
+ // Try baseURI + relavtive schema path combo
+ else {
+ pathURI = new URI(baseUri);
+ pathURI = pathURI.resolve(schemaLocation);
+ String pathURIStr = pathURI.toString();
+
+ // If path is absolute, build URL directly from it
+ if (isAbsolute(pathURIStr)) {
+ is = getInputStreamForURI(pathURIStr);
+ }
+
+ // if the location is relative, we need to resolve the
+ // location using
+ // the baseURI, then use the loadStrategy to gain an input
+ // stream
+ // because the URI will still be relative to the module
+ else {
+ // is = loadStrategy.getInputStream(pathURI.toString());
+ is = classLoader
+ .getResourceAsStream(pathURI.toString());
+ }
+ }
+ } catch (Exception e) {
+ // TODO: RAS
+// Object[] inserts = { schemaLocation, e };
+ }
+ }
+
+ // if(is == null){
+ // Object[] inserts = { schemaLocation };
+ // String msg = NLSProvider.getNLS().getFormattedMessage(
+ // "fileNotFound00", inserts,
+ // "File {0} could not be found.");
+ // throw new RuntimeException(msg);
+ // }
+ //
+ // if(_tc.isDebugEnabled()){
+ // Tr.debug(_tc, "Loaded file: " + schemaLocation + ", base URI: " +
+ // baseUri);
+ // }
+ //
+ // if (_tc.isEntryEnabled()) {
+ // Tr.exit(_tc, "resolveEntity");
+ // }
+
+ return new InputSource(is);
+ }
+
+ /**
+ * Checks to see if the location given is an absolute (actual) or relative
+ * path.
+ *
+ * @param location
+ * @return
+ */
+ private boolean isAbsolute(String location) {
+ boolean absolute = false;
+ if (location.indexOf(":/") != -1) {
+ absolute = true;
+ } else if (location.indexOf(":\\") != -1) {
+ absolute = true;
+ }
+ return absolute;
+ }
+
+ /**
+ * Gets input stream from the uri given. If we cannot find the stream,
+ * <code>null</code> is returned.
+ *
+ * @param uri
+ * @return
+ */
+ private InputStream getInputStreamForURI(String uri) {
+ URL streamURL = null;
+ InputStream is = null;
+ URI pathURI = null;
+
+ try {
+ streamURL = new URL(uri);
+ is = streamURL.openStream();
+ } catch (Throwable t) {
+ //No FFDC required
+ }
+
+ if (is == null) {
+ try {
+ pathURI = new URI(uri);
+ streamURL = pathURI.toURL();
+ is = streamURL.openStream();
+ } catch (Throwable t) {
+ //No FFDC required
+ }
+ }
+
+ if (is == null) {
+ try {
+ File file = new File(uri);
+ streamURL = file.toURL();
+ is = streamURL.openStream();
+ } catch (Throwable t) {
+ //No FFDC required
+ }
+ }
+
+ return is;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java?view=diff&rev=484636&r1=484635&r2=484636
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java Fri Dec 8 07:27:01 2006
@@ -18,7 +18,10 @@
package org.apache.axis2.jaxws.util;
+import java.io.InputStream;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -37,6 +40,8 @@
import javax.wsdl.xml.WSDLReader;
import javax.xml.namespace.QName;
+import org.apache.axis2.AxisFault;
+
public class WSDL4JWrapper implements WSDLWrapper {
@@ -49,8 +54,19 @@
this.wsdlURL = wsdlURL;
WSDLFactory factory = WSDLFactory.newInstance();
WSDLReader reader = factory.newWSDLReader();
- wsdlDefinition = reader.readWSDL(wsdlURL.toString());
+ try {
+ URL url = new URL(wsdlURL.toString());
+ URLConnection urlCon = url.openConnection();
+ InputStream is = urlCon.getInputStream();
+ is.close();
+ String explicitWsdl = urlCon.getURL().toString();
+
+ wsdlDefinition = reader.readWSDL(explicitWsdl);
+
+ } catch (Exception ex) {
+ throw new WSDLException("WSDL4JWrapper : ", ex.getMessage());
+ }
}
public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition) throws WSDLException{
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org