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 di...@apache.org on 2008/02/25 20:09:05 UTC
svn commit: r630959 [4/4] - in /webservices/axis2/trunk/java/modules: jaxws/
jaxws/test-resources/catalog/ jaxws/test-resources/catalog/dir1/
jaxws/test-resources/catalog/dir2/ jaxws/test-resources/catalog/dir3/
jaxws/test-resources/catalog/fail/ jaxws...
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/BaseWSDLLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/BaseWSDLLocator.java?rev=630959&r1=630958&r2=630959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/BaseWSDLLocator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/BaseWSDLLocator.java Mon Feb 25 11:09:01 2008
@@ -1,259 +1,272 @@
-/*
- * 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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.StringTokenizer;
-
-import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.xml.sax.InputSource;
-
-
-/**
- * This class is the base for an implementation of a WSDL4J interface that
- * will be supplied to a WSDLReader instance. Its primary goal is to assist
- * with locating imported WSDL documents.
- */
-public abstract class BaseWSDLLocator {
-
- private static Log log = LogFactory.getLog(BaseWSDLLocator.class);
-
- protected String baseURI, lastestImportURI;
- protected InputStream baseInputStream;
-
- /**
- * Returns an InputStream pointed at an imported wsdl pathname relative
- * to the parent resource or loadStrategy.
- *
- * @param importPath identifies the WSDL file within the context
- * @return an stream of the WSDL file
- */
- abstract protected InputStream getInputStream(String importPath) throws IOException;
-
- /**
- * Returns an InputSource "pointed at" the base document.
- */
- public InputSource getBaseInputSource() {
- return new InputSource(baseInputStream);
- }
-
- /**
- * Returns an InputSource pointed at an imported wsdl document whose
- * parent document was located at parentLocation and whose
- * relative location to the parent document is specified by
- * relativeLocation.
- *
- * @param parentLocation a URI specifying the location of the
- * document doing the importing.
- * @param relativeLocation a URI specifying the location of the
- * document to import, relative to the parent document's location.
- */
- public InputSource getImportInputSource(String parentLocation, String relativeLocation) {
- if (log.isDebugEnabled()) {
- log.debug("getImportInputSource, parentLocation= " + parentLocation +
- " relativeLocation= " + relativeLocation);
- }
- InputSource inputSource = null;
- InputStream is = null;
- URL absoluteURL = null;
-
- try {
- if (isAbsoluteImport(relativeLocation)) {
- try{
- absoluteURL = new URL(relativeLocation);
- is = absoluteURL.openStream();
- lastestImportURI = absoluteURL.toExternalForm();
- }
- catch(Throwable t){
- //No FFDC code needed
- }
- if(is == null){
- try{
- URI fileURI = new URI(relativeLocation);
- absoluteURL = fileURI.toURL();
- is = absoluteURL.openStream();
- lastestImportURI = absoluteURL.toExternalForm();
- }
- catch(Throwable t){
- //No FFDC code needed
- }
- }
- if(is == null){
- try{
- File file = new File(relativeLocation);
- absoluteURL = file.toURL();
- is = absoluteURL.openStream();
- lastestImportURI = absoluteURL.toExternalForm();
- }
- catch(Throwable t){
- //No FFDC code needed
- }
- }
-
- } else {
- String importPath = normalizePath(parentLocation, relativeLocation);
- is = getInputStream(importPath);
- lastestImportURI = importPath;
- }
- } catch (IOException ex) {
- throw ExceptionFactory.makeWebServiceException("An error occurred while attempting "
- + " to resolve the " + relativeLocation + " WSDL file: " + ex.toString());
- }
- if(is == null){
- throw ExceptionFactory.makeWebServiceException("The " + relativeLocation +
- " WSDL file could not be located.");
- }
- if(log.isDebugEnabled()){
- log.debug("Loaded file: " + relativeLocation);
- }
- return new InputSource(is);
- }
-
- /**
- * Returns a URI representing the location of the base document.
- */
- public String getBaseURI() {
- return baseURI;
-
- }
-
- /**
- * Returns a URI representing the location of the last import document
- * to be resolved. This is useful when resolving nested imports.
- */
- public String getLatestImportURI() {
- return lastestImportURI;
- }
-
- /*
- * @param rawURI the uri for base wsdl file, which could be the form of
- * META-INF/base.wsdl or just base.wsdl, but it can be /base.wsdl (no leading slash according to spec)
- * @return the uri which is one level up the raw uri with the trailing slash (if not empty)
- *
- */
- protected String convertURI(String rawURI) {
- int idx = rawURI.lastIndexOf('/');
- if(idx > 0) {
- rawURI = rawURI.substring(0, idx + 1);
- return rawURI;
- }
- // this may be an absolute file reference
- else {
- idx = rawURI.lastIndexOf('\\');
- if(idx > 0) {
- rawURI = rawURI.substring(0, idx + 1);
- return rawURI;
- }
- return "";
- }
- }
-
- protected boolean isAbsoluteImport(String uri) {
- boolean absolute = false;
- if(uri != null){
- if(uri.indexOf(":/") != -1){
- absolute = true;
- }
- else if(uri.indexOf(":\\") != -1){
- absolute = true;
- }
- }
-
- return absolute;
- }
-
- /**
- * The ZipFile can not handle relative imports of that have directory components
- * of the form "..". Given a 'relativeLocation' relative to 'parentLocation', replace
- * any ".." with actual path component names.
- * @param parentLocation Path relative to the module root of the file that is doing the
- * importing.
- * @param relativeLocation Path relative to the parentLocation of the file that is being imported.
- * @return String contatining the path to the file being imported (i.e. relativeLocation) that is
- * relative to the module root and has all ".." and "." path components removed and replaced
- * with the corresponding actual directory name.
- */
- private static final char WSDL_PATH_SEPERATOR_CHAR = '/';
- private static final String WSDL_PATH_SEPERATOR =
- (new Character(WSDL_PATH_SEPERATOR_CHAR)).toString();
-
- protected String normalizePath(String parentLocation, String relativeLocation) {
- if (log.isDebugEnabled()) {
- log.debug("normalizePath, parentLocation= " + parentLocation +
- " relativeLocation= " + relativeLocation);
- }
- // Get the path from the module root to the directory containing the importing WSDL file.
- // Note this path will end in a "/" and will not contain any ".." path components.
- String pathFromRoot = convertURI(parentLocation);
-
- // Construct the path to the location relative to the module root based on the parent location,
- // removing any ".." or "." path components.
- StringBuffer pathToRelativeLocation = new StringBuffer(pathFromRoot);
- StringTokenizer tokenizedRelativeLocation =
- new StringTokenizer(relativeLocation, WSDL_PATH_SEPERATOR);
- if (log.isDebugEnabled()) {
- log.debug("pathFromRoot = " + pathFromRoot);
- log.debug("relativeLocation = " + relativeLocation);
- }
- while (tokenizedRelativeLocation.hasMoreTokens()) {
- String nextToken = tokenizedRelativeLocation.nextToken();
- if (nextToken.equals("..")) {
- // Relative parent directory, so chop off the last path component in the path to back
- // up to the parent directory. First delete the trailing "/" from the path if there
- // is one, then delete characters from the end of the path until we find the next "/".
- int charToDelete = pathToRelativeLocation.length() - 1;
- if (pathToRelativeLocation.charAt(charToDelete) == WSDL_PATH_SEPERATOR_CHAR ||
- pathToRelativeLocation.charAt(charToDelete) == '\\') {
- pathToRelativeLocation.deleteCharAt(charToDelete--);
- }
- while (pathToRelativeLocation.charAt(charToDelete) != WSDL_PATH_SEPERATOR_CHAR &&
- pathToRelativeLocation.charAt(charToDelete) != '\\') {
- pathToRelativeLocation.deleteCharAt(charToDelete--);
- }
- } else if (nextToken.equals(".")) {
- // Relative current directory, do not add or delete any path components
- } else {
- // Make sure the current path ends in a "/" or "\\" then append this path component
- // This handles locations within the module and URIs
- if ((pathToRelativeLocation.indexOf(String.valueOf(WSDL_PATH_SEPERATOR_CHAR))
- != -1) && (pathToRelativeLocation.charAt(pathToRelativeLocation.length()
- - 1)!= WSDL_PATH_SEPERATOR_CHAR)) {
- pathToRelativeLocation.append(WSDL_PATH_SEPERATOR_CHAR);
- }
- // This handles file based locations
- else if((pathToRelativeLocation.indexOf("\\") != -1) && (pathToRelativeLocation.
- charAt(pathToRelativeLocation.length() -1) != '\\')) {
- pathToRelativeLocation.append('\\');
- }
- pathToRelativeLocation.append(nextToken);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Built path = " + pathToRelativeLocation.toString());
- }
- return pathToRelativeLocation.toString();
- }
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.util.StringTokenizer;
+
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.InputSource;
+
+
+/**
+ * This class is the base for an implementation of a WSDL4J interface that
+ * will be supplied to a WSDLReader instance. Its primary goal is to assist
+ * with locating imported WSDL documents.
+ */
+public abstract class BaseWSDLLocator {
+
+ private static Log log = LogFactory.getLog(BaseWSDLLocator.class);
+
+ protected String baseURI, lastestImportURI;
+ protected InputStream baseInputStream;
+
+ /**
+ * Returns an InputStream pointed at an imported wsdl pathname relative
+ * to the parent resource or loadStrategy.
+ *
+ * @param importPath identifies the WSDL file within the context
+ * @return an stream of the WSDL file
+ */
+ abstract protected InputStream getInputStream(String importPath) throws IOException;
+
+ /**
+ * Allows for a level of indirection, such as a catalog, when importing URIs.
+ *
+ * @param importURI a URI specifying the document to import
+ * @param parent a URI specifying the location of the parent document doing
+ * the importing
+ * @return the resolved import location, or null if no indirection is performed
+ */
+ abstract protected String getRedirectedURI(String importURI, String parent);
+
+ /**
+ * Returns an InputSource "pointed at" the base document.
+ */
+ public InputSource getBaseInputSource() {
+ return new InputSource(baseInputStream);
+ }
+
+ /**
+ * Returns an InputSource pointed at an imported wsdl document whose
+ * parent document was located at parentLocation and whose
+ * relative location to the parent document is specified by
+ * relativeLocation.
+ *
+ * @param parentLocation a URI specifying the location of the
+ * document doing the importing.
+ * @param relativeLocation a URI specifying the location of the
+ * document to import, relative to the parent document's location.
+ */
+ public InputSource getImportInputSource(String parentLocation, String relativeLocation) {
+ if (log.isDebugEnabled()) {
+ log.debug("getImportInputSource, parentLocation= " + parentLocation +
+ " relativeLocation= " + relativeLocation);
+ }
+ InputStream is = null;
+ URL absoluteURL = null;
+
+ String redirectedURI = getRedirectedURI(relativeLocation, parentLocation);
+ if (redirectedURI != null)
+ relativeLocation = redirectedURI;
+
+ try {
+ if (isAbsoluteImport(relativeLocation)) {
+ try{
+ absoluteURL = new URL(relativeLocation);
+ is = absoluteURL.openStream();
+ lastestImportURI = absoluteURL.toExternalForm();
+ }
+ catch(Throwable t){
+ //No FFDC code needed
+ }
+ if(is == null){
+ try{
+ URI fileURI = new URI(relativeLocation);
+ absoluteURL = fileURI.toURL();
+ is = absoluteURL.openStream();
+ lastestImportURI = absoluteURL.toExternalForm();
+ }
+ catch(Throwable t){
+ //No FFDC code needed
+ }
+ }
+ if(is == null){
+ try{
+ File file = new File(relativeLocation);
+ absoluteURL = file.toURL();
+ is = absoluteURL.openStream();
+ lastestImportURI = absoluteURL.toExternalForm();
+ }
+ catch(Throwable t){
+ //No FFDC code needed
+ }
+ }
+
+ } else {
+ String importPath = normalizePath(parentLocation, relativeLocation);
+ is = getInputStream(importPath);
+ lastestImportURI = importPath;
+ }
+ } catch (IOException ex) {
+ throw ExceptionFactory.makeWebServiceException("An error occurred while attempting "
+ + " to resolve the " + relativeLocation + " WSDL file: " + ex.toString());
+ }
+ if(is == null){
+ throw ExceptionFactory.makeWebServiceException("The " + relativeLocation +
+ " WSDL file could not be located.");
+ }
+ if(log.isDebugEnabled()){
+ log.debug("Loaded file: " + relativeLocation);
+ }
+ return new InputSource(is);
+ }
+
+ /**
+ * Returns a URI representing the location of the base document.
+ */
+ public String getBaseURI() {
+ return baseURI;
+
+ }
+
+ /**
+ * Returns a URI representing the location of the last import document
+ * to be resolved. This is useful when resolving nested imports.
+ */
+ public String getLatestImportURI() {
+ return lastestImportURI;
+ }
+
+ /*
+ * @param rawURI the uri for base wsdl file, which could be the form of
+ * META-INF/base.wsdl or just base.wsdl, but it can be /base.wsdl (no leading slash according to spec)
+ * @return the uri which is one level up the raw uri with the trailing slash (if not empty)
+ *
+ */
+ protected String convertURI(String rawURI) {
+ int idx = rawURI.lastIndexOf('/');
+ if(idx > 0) {
+ rawURI = rawURI.substring(0, idx + 1);
+ return rawURI;
+ }
+ // this may be an absolute file reference
+ else {
+ idx = rawURI.lastIndexOf('\\');
+ if(idx > 0) {
+ rawURI = rawURI.substring(0, idx + 1);
+ return rawURI;
+ }
+ return "";
+ }
+ }
+
+ protected boolean isAbsoluteImport(String uri) {
+ boolean absolute = false;
+ if(uri != null){
+ if(uri.indexOf(":/") != -1){
+ absolute = true;
+ }
+ else if(uri.indexOf(":\\") != -1){
+ absolute = true;
+ }
+ }
+
+ return absolute;
+ }
+
+ /**
+ * The ZipFile can not handle relative imports of that have directory components
+ * of the form "..". Given a 'relativeLocation' relative to 'parentLocation', replace
+ * any ".." with actual path component names.
+ * @param parentLocation Path relative to the module root of the file that is doing the
+ * importing.
+ * @param relativeLocation Path relative to the parentLocation of the file that is being imported.
+ * @return String contatining the path to the file being imported (i.e. relativeLocation) that is
+ * relative to the module root and has all ".." and "." path components removed and replaced
+ * with the corresponding actual directory name.
+ */
+ private static final char WSDL_PATH_SEPERATOR_CHAR = '/';
+ private static final String WSDL_PATH_SEPERATOR =
+ (new Character(WSDL_PATH_SEPERATOR_CHAR)).toString();
+
+ protected String normalizePath(String parentLocation, String relativeLocation) {
+ if (log.isDebugEnabled()) {
+ log.debug("normalizePath, parentLocation= " + parentLocation +
+ " relativeLocation= " + relativeLocation);
+ }
+ // Get the path from the module root to the directory containing the importing WSDL file.
+ // Note this path will end in a "/" and will not contain any ".." path components.
+ String pathFromRoot = convertURI(parentLocation);
+
+ // Construct the path to the location relative to the module root based on the parent location,
+ // removing any ".." or "." path components.
+ StringBuffer pathToRelativeLocation = new StringBuffer(pathFromRoot);
+ StringTokenizer tokenizedRelativeLocation =
+ new StringTokenizer(relativeLocation, WSDL_PATH_SEPERATOR);
+ if (log.isDebugEnabled()) {
+ log.debug("pathFromRoot = " + pathFromRoot);
+ log.debug("relativeLocation = " + relativeLocation);
+ }
+ while (tokenizedRelativeLocation.hasMoreTokens()) {
+ String nextToken = tokenizedRelativeLocation.nextToken();
+ if (nextToken.equals("..")) {
+ // Relative parent directory, so chop off the last path component in the path to back
+ // up to the parent directory. First delete the trailing "/" from the path if there
+ // is one, then delete characters from the end of the path until we find the next "/".
+ int charToDelete = pathToRelativeLocation.length() - 1;
+ if (pathToRelativeLocation.charAt(charToDelete) == WSDL_PATH_SEPERATOR_CHAR ||
+ pathToRelativeLocation.charAt(charToDelete) == '\\') {
+ pathToRelativeLocation.deleteCharAt(charToDelete--);
+ }
+ while (pathToRelativeLocation.charAt(charToDelete) != WSDL_PATH_SEPERATOR_CHAR &&
+ pathToRelativeLocation.charAt(charToDelete) != '\\') {
+ pathToRelativeLocation.deleteCharAt(charToDelete--);
+ }
+ } else if (nextToken.equals(".")) {
+ // Relative current directory, do not add or delete any path components
+ } else {
+ // Make sure the current path ends in a "/" or "\\" then append this path component
+ // This handles locations within the module and URIs
+ if ((pathToRelativeLocation.indexOf(String.valueOf(WSDL_PATH_SEPERATOR_CHAR))
+ != -1) && (pathToRelativeLocation.charAt(pathToRelativeLocation.length()
+ - 1)!= WSDL_PATH_SEPERATOR_CHAR)) {
+ pathToRelativeLocation.append(WSDL_PATH_SEPERATOR_CHAR);
+ }
+ // This handles file based locations
+ else if((pathToRelativeLocation.indexOf("\\") != -1) && (pathToRelativeLocation.
+ charAt(pathToRelativeLocation.length() -1) != '\\')) {
+ pathToRelativeLocation.append('\\');
+ }
+ pathToRelativeLocation.append(nextToken);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Built path = " + pathToRelativeLocation.toString());
+ }
+ return pathToRelativeLocation.toString();
+ }
}
Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogURIResolver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogURIResolver.java?rev=630959&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogURIResolver.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogURIResolver.java Mon Feb 25 11:09:01 2008
@@ -0,0 +1,209 @@
+/*
+ * 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.util;
+
+import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+import org.apache.xml.resolver.Catalog;
+
+import org.xml.sax.InputSource;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+
+/**
+ * This resolver provides the means of resolving the imports and includes of a
+ * given schema document. It allows the use of the Apache Commons Resolver API
+ * to redirect resource requests to alternative locations.
+ */
+public class CatalogURIResolver implements URIResolver {
+
+ private static Log log = LogFactory.getLog(CatalogWSDLLocator.class);
+ private Catalog catalogResolver;
+
+ /**
+ * CatalogURIResolver constructor. Resolves WSDL URIs using Apache Commons Resolver API.
+ * @param catalogManager
+ * the OASISCatalogManager which will determine the settings for the XML catalog
+ */
+
+ public CatalogURIResolver(JAXWSCatalogManager catalogManager) {
+ this.catalogResolver = catalogManager.getCatalog();
+ }
+
+ /**
+ * Resolves URIs using Apache Commons Resolver API.
+ *
+ * @param importURI a URI specifying the document to import
+ * @param parent a URI specifying the location of the parent document doing
+ * the importing
+ * @return the resolved import location, or null if no indirection is performed
+ */
+ public String getRedirectedURI(String importURI, String parent) {
+ String resolvedImportLocation = null;
+ try {
+ resolvedImportLocation = this.catalogResolver.resolveSystem(importURI);
+ if (resolvedImportLocation == null) {
+ resolvedImportLocation = catalogResolver.resolveURI(importURI);
+ }
+ if (resolvedImportLocation == null) {
+ resolvedImportLocation = catalogResolver.resolvePublic(importURI, parent);
+ }
+
+ } catch (IOException e) {
+ throw new RuntimeException("Catalog resolution failed", e);
+ }
+
+ return resolvedImportLocation;
+ }
+
+ /**
+ * As for the resolver the public ID is the target namespace of the
+ * schema and the schemaLocation is the value of the schema location
+ * @param namespace
+ * @param schemaLocation
+ * @param baseUri
+ */
+ public InputSource resolveEntity(String namespace,
+ String schemaLocation,
+ String baseUri){
+
+ if (baseUri!=null)
+ {
+ String redirectedURI = getRedirectedURI(namespace, baseUri);
+ if (redirectedURI != null)
+ schemaLocation = redirectedURI;
+ try
+ {
+ File baseFile = new File(baseUri);
+ if (baseFile.exists()) baseUri = baseFile.toURI().toString();
+
+ String ref = new URI(baseUri).resolve(new URI(schemaLocation)).toString();
+
+ return new InputSource(ref);
+ }
+ catch (URISyntaxException e1)
+ {
+ throw new RuntimeException(e1);
+ }
+
+ }
+ return new InputSource(schemaLocation);
+
+ }
+
+ /**
+ * Find whether a given uri is relative or not
+ *
+ * @param uri
+ * @return boolean
+ */
+ protected boolean isAbsolute(String uri) {
+ return uri.startsWith("http://");
+ }
+
+ /**
+ * This is essentially a call to "new URL(contextURL, spec)"
+ * with extra handling in case spec is
+ * a file.
+ *
+ * @param contextURL
+ * @param spec
+ * @throws java.io.IOException
+ */
+ protected URL getURL(URL contextURL, String spec) throws IOException {
+
+ // First, fix the slashes as windows filenames may have backslashes
+ // in them, but the URL class wont do the right thing when we later
+ // process this URL as the contextURL.
+ String path = spec.replace('\\', '/');
+
+ // See if we have a good URL.
+ URL url;
+
+ try {
+
+ // first, try to treat spec as a full URL
+ url = new URL(contextURL, path);
+
+ // if we are deail with files in both cases, create a url
+ // by using the directory of the context URL.
+ if ((contextURL != null) && url.getProtocol().equals("file")
+ && contextURL.getProtocol().equals("file")) {
+ url = getFileURL(contextURL, path);
+ }
+ } catch (MalformedURLException me) {
+
+ // try treating is as a file pathname
+ url = getFileURL(contextURL, path);
+ }
+
+ // Everything is OK with this URL, although a file url constructed
+ // above may not exist. This will be caught later when the URL is
+ // accessed.
+ return url;
+ } // getURL
+
+ /**
+ * Method getFileURL
+ *
+ * @param contextURL
+ * @param path
+ * @throws IOException
+ */
+ protected URL getFileURL(URL contextURL, String path)
+ throws IOException {
+
+ if (contextURL != null) {
+
+ // get the parent directory of the contextURL, and append
+ // the spec string to the end.
+ String contextFileName = contextURL.getFile();
+ URL parent = null;
+ //the logic for finding the parent file is this.
+ //1.if the contextURI represents a file then take the parent file
+ //of it
+ //2. If the contextURI represents a directory, then take that as
+ //the parent
+ File parentFile;
+ File contextFile = new File(contextFileName);
+ if (contextFile.isDirectory()){
+ parentFile = contextFile;
+ }else{
+ parentFile = contextFile.getParentFile();
+ }
+
+ if (parentFile != null) {
+ parent = parentFile.toURL();
+ }
+ if (parent != null) {
+ return new URL(parent, path);
+ }
+ }
+
+ return new URL("file", "", path);
+ } // getFileURL
+}
Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogWSDLLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogWSDLLocator.java?rev=630959&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogWSDLLocator.java (added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/CatalogWSDLLocator.java Mon Feb 25 11:09:01 2008
@@ -0,0 +1,204 @@
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.xml.resolver.Catalog;
+
+/**
+ * This class is an implementation of a WSDL4J interface and is the
+ * implementation we supply to a WSDLReader instance. Its primary
+ * goal is to assist with locating imported WSDL documents.
+ *
+ */
+public class CatalogWSDLLocator extends BaseWSDLLocator implements WSDLLocator {
+
+ private static Log log = LogFactory.getLog(CatalogWSDLLocator.class);
+ private Catalog catalogResolver;
+ private ClassLoader classLoader;
+
+ /**
+ * CatalogWSDLLocator constructor. Resolves WSDL URIs using Apache Commons Resolver API.
+ * @param uri
+ * the path for the base wsdl file, relative to the module root
+ * @param stream
+ * the InputStream for the base wsdl file
+ * @param classloader
+ * the ClassLoader for the module
+ * @param catalogManager
+ * the OASISCatalogManager which will determine the settings for the XML catalog
+ */
+ public CatalogWSDLLocator(String uri, InputStream stream,
+ ClassLoader classLoader, JAXWSCatalogManager catalogManager) {
+ baseURI = convertURI(uri);
+ baseInputStream = stream;
+ this.classLoader = classLoader;
+ this.catalogResolver = catalogManager.getCatalog();
+ }
+
+ /**
+ * Resolves WSDL URIs using Apache Commons Resolver API.
+ *
+ * @param importURI a URI specifying the document to import
+ * @param parent a URI specifying the location of the parent document doing
+ * the importing
+ * @return the resolved import location, or null if no indirection is performed
+ */
+ public String getRedirectedURI(String importURI, String parent) {
+ String resolvedImportLocation = null;
+
+ try {
+ resolvedImportLocation = this.catalogResolver.resolveSystem(importURI);
+ if (resolvedImportLocation == null) {
+ resolvedImportLocation = catalogResolver.resolveURI(importURI);
+ }
+ if (resolvedImportLocation == null) {
+ resolvedImportLocation = catalogResolver.resolvePublic(importURI, parent);
+ }
+
+ } catch (IOException e) {
+ throw new RuntimeException("Catalog resolution failed", e);
+ }
+ return resolvedImportLocation;
+ }
+
+ /**
+ * Returns an InputStream pointed at an imported wsdl pathname relative to
+ * the parent document.
+ *
+ * @param importPath
+ * identifies the WSDL file within the context
+ * @return a stream of the WSDL file
+ */
+ protected InputStream getInputStream(String importPath) throws IOException {
+ URL importURL = null;
+ InputStream is = null;
+ try {
+ importURL = new URL(importPath);
+ is = importURL.openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ if (is == null) {
+ try {
+ is = classLoader.getResourceAsStream(importPath);
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ if (is == null) {
+ try {
+ File file = new File(importPath);
+ is = file.toURL().openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ if (is == null) {
+ try {
+ URI uri = new URI(importPath);
+ is = uri.toURL().openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ return is;
+ }
+
+ /**
+ * Return the wsdlLocation in URL form. WsdlLocation could be URL, relative
+ * module path, full absolute path.
+ *
+ * @param wsdlLocation
+ * the location of a WSDL document in the form of a URL string, a
+ * relative pathname (relative to the root of a module, or a
+ * full-qualified absolute pathname
+ * @return the location of the WSDL document in the form of a URL
+ */
+ public URL getWsdlUrl(String wsdlLocation) {
+ URL streamURL = null;
+ InputStream is = null;
+ URI pathURI = null;
+
+ // If the WSDL is present in the catalog, use the location specified
+ // in the catalog. If this attempt results in failure, use the original
+ // location
+ // TODO: Provide Allowance for Catalog
+ // Note: This method is not called.
+
+ try {
+ streamURL = new URL(wsdlLocation);
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+
+ if (is == null) {
+ try {
+ pathURI = new URI(wsdlLocation);
+ streamURL = pathURI.toURL();
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+
+ if (is == null) {
+ try {
+ File file = new File(wsdlLocation);
+ streamURL = file.toURL();
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+
+ if (log.isDebugEnabled() && streamURL == null) {
+ log.debug("Absolute wsdlLocation could not be determined: "
+ + wsdlLocation);
+ }
+
+ return streamURL;
+ }
+
+ public void close() {
+ }
+}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/ModuleWSDLLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/ModuleWSDLLocator.java?rev=630959&r1=630958&r2=630959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/ModuleWSDLLocator.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/ModuleWSDLLocator.java Mon Feb 25 11:09:01 2008
@@ -1,167 +1,179 @@
-/*
- * 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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-
-import javax.wsdl.xml.WSDLLocator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * This class is an implementation of a WSDL4J interface and is the
- * implementation we supply to a WSDLReader instance. Its primary
- * goal is to assist with locating imported WSDL documents.
- *
- */
-public class ModuleWSDLLocator extends BaseWSDLLocator implements WSDLLocator {
-
- private static Log log = LogFactory.getLog(ModuleWSDLLocator.class);
-
- private ClassLoader classLoader;
-
- /**
- * ModuleWSDLLocator constructor.
- * @param uri
- * the path for the base wsdl file, relative to the module root
- * @param stream
- * the InputStream for the base wsdl file
- * @param strategy
- * the load stragety for the module
- */
- public ModuleWSDLLocator(String uri, InputStream stream,
- ClassLoader classLoader) {
- baseURI = convertURI(uri);
- baseInputStream = stream;
- this.classLoader = classLoader;
- }
-
- /**
- * Returns an InputStream pointed at an imported wsdl pathname relative to
- * the parent document.
- *
- * @param importPath
- * identifies the WSDL file within the context
- * @return a stream of the WSDL file
- */
- protected InputStream getInputStream(String importPath) throws IOException {
- URL importURL = null;
- InputStream is = null;
- try {
- importURL = new URL(importPath);
- is = importURL.openStream();
- }
- catch (Throwable t) {
- // No FFDC required
- }
- if (is == null) {
- try {
- is = classLoader.getResourceAsStream(importPath);
- }
- catch (Throwable t) {
- // No FFDC required
- }
- }
- if (is == null) {
- try {
- File file = new File(importPath);
- is = file.toURL().openStream();
- }
- catch (Throwable t) {
- // No FFDC required
- }
- }
- if (is == null) {
- try {
- URI uri = new URI(importPath);
- is = uri.toURL().openStream();
- }
- catch (Throwable t) {
- // No FFDC required
- }
- }
- return is;
- }
-
- /**
- * Return the wsdlLocation in URL form. WsdlLocation could be URL, relative
- * module path, full absolute path.
- *
- * @param wsdlLocation
- * the location of a WSDL document in the form of a URL string, a
- * relative pathname (relative to the root of a module, or a
- * full-qualified absolute pathname
- * @return the location of the WSDL document in the form of a URL
- */
- public URL getWsdlUrl(String wsdlLocation) {
- URL streamURL = null;
- InputStream is = null;
- URI pathURI = null;
-
- try {
- streamURL = new URL(wsdlLocation);
- is = streamURL.openStream();
- is.close();
- }
- catch (Throwable t) {
- // No FFDC required
- }
-
- if (is == null) {
- try {
- pathURI = new URI(wsdlLocation);
- streamURL = pathURI.toURL();
- is = streamURL.openStream();
- is.close();
- }
- catch (Throwable t) {
- // No FFDC required
- }
- }
-
- if (is == null) {
- try {
- File file = new File(wsdlLocation);
- streamURL = file.toURL();
- is = streamURL.openStream();
- is.close();
- }
- catch (Throwable t) {
- // No FFDC required
- }
- }
-
- if (log.isDebugEnabled() && streamURL == null) {
- log.debug("Absolute wsdlLocation could not be determined: "
- + wsdlLocation);
- }
-
- return streamURL;
- }
-
- public void close() {
- }
+/*
+ * 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.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URL;
+
+import javax.wsdl.xml.WSDLLocator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This class is an implementation of a WSDL4J interface and is the
+ * implementation we supply to a WSDLReader instance. Its primary
+ * goal is to assist with locating imported WSDL documents.
+ *
+ */
+public class ModuleWSDLLocator extends BaseWSDLLocator implements WSDLLocator {
+
+ private static Log log = LogFactory.getLog(ModuleWSDLLocator.class);
+
+ private ClassLoader classLoader;
+
+ /**
+ * ModuleWSDLLocator constructor.
+ * @param uri
+ * the path for the base wsdl file, relative to the module root
+ * @param stream
+ * the InputStream for the base wsdl file
+ * @param strategy
+ * the load strategy for the module
+ */
+ public ModuleWSDLLocator(String uri, InputStream stream,
+ ClassLoader classLoader) {
+ baseURI = convertURI(uri);
+ baseInputStream = stream;
+ this.classLoader = classLoader;
+ }
+
+ /**
+ * Returns null because no URI indirection is performed when
+ * using the ModuleWSDLLocator.
+ *
+ * @param importURI a URI specifying the document to import
+ * @param parent a URI specifying the location of the parent document doing
+ * the importing
+ * @return null
+ */
+ protected String getRedirectedURI(String importURI, String parent) {
+ return null;
+ }
+
+ /**
+ * Returns an InputStream pointed at an imported wsdl pathname relative to
+ * the parent document.
+ *
+ * @param importPath
+ * identifies the WSDL file within the context
+ * @return a stream of the WSDL file
+ */
+ protected InputStream getInputStream(String importPath) throws IOException {
+ URL importURL = null;
+ InputStream is = null;
+ try {
+ importURL = new URL(importPath);
+ is = importURL.openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ if (is == null) {
+ try {
+ is = classLoader.getResourceAsStream(importPath);
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ if (is == null) {
+ try {
+ File file = new File(importPath);
+ is = file.toURL().openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ if (is == null) {
+ try {
+ URI uri = new URI(importPath);
+ is = uri.toURL().openStream();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+ return is;
+ }
+
+ /**
+ * Return the wsdlLocation in URL form. WsdlLocation could be URL, relative
+ * module path, full absolute path.
+ *
+ * @param wsdlLocation
+ * the location of a WSDL document in the form of a URL string, a
+ * relative pathname (relative to the root of a module, or a
+ * full-qualified absolute pathname
+ * @return the location of the WSDL document in the form of a URL
+ */
+ public URL getWsdlUrl(String wsdlLocation) {
+ URL streamURL = null;
+ InputStream is = null;
+ URI pathURI = null;
+
+ try {
+ streamURL = new URL(wsdlLocation);
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+
+ if (is == null) {
+ try {
+ pathURI = new URI(wsdlLocation);
+ streamURL = pathURI.toURL();
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+
+ if (is == null) {
+ try {
+ File file = new File(wsdlLocation);
+ streamURL = file.toURL();
+ is = streamURL.openStream();
+ is.close();
+ }
+ catch (Throwable t) {
+ // No FFDC required
+ }
+ }
+
+ if (log.isDebugEnabled() && streamURL == null) {
+ log.debug("Absolute wsdlLocation could not be determined: "
+ + wsdlLocation);
+ }
+
+ return streamURL;
+ }
+
+ public void close() {
+ }
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java?rev=630959&r1=630958&r2=630959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDL4JWrapper.java Mon Feb 25 11:09:01 2008
@@ -25,6 +25,8 @@
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.java.security.AccessController;
import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.catalog.JAXWSCatalogManager;
+import org.apache.axis2.jaxws.catalog.impl.OASISCatalogManager;
import org.apache.axis2.jaxws.i18n.Messages;
import org.apache.axis2.jaxws.wsdl.WSDLReaderConfigurator;
import org.apache.axis2.metadata.factory.ResourceFinderFactory;
@@ -50,7 +52,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.ConnectException;
-import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
@@ -75,7 +76,7 @@
private URL wsdlURL;
private String wsdlExplicitURL;
private ConfigurationContext configContext;
-
+ private JAXWSCatalogManager catalogManager = null;
/**
* Constructor
*
@@ -83,14 +84,35 @@
*/
public WSDL4JWrapper(URL wsdlURL) throws FileNotFoundException, UnknownHostException,
ConnectException, IOException, WSDLException {
- this(wsdlURL, (ConfigurationContext)null);
+ super();
+ this.commonPartsURLConstructor(wsdlURL, (ConfigurationContext)null);
}
- public WSDL4JWrapper(URL wsdlURL, ConfigurationContext configContext) throws FileNotFoundException, UnknownHostException,
- ConnectException, IOException, WSDLException {
+ public WSDL4JWrapper(URL wsdlURL, JAXWSCatalogManager catalogManager) throws FileNotFoundException,
+ UnknownHostException, ConnectException, IOException, WSDLException {
super();
+ this.catalogManager = catalogManager;
+ this.commonPartsURLConstructor(wsdlURL, (ConfigurationContext)null);
+ }
+
+ public WSDL4JWrapper(URL wsdlURL, ConfigurationContext configContext,
+ JAXWSCatalogManager catalogManager) throws FileNotFoundException,
+ UnknownHostException, ConnectException, IOException, WSDLException {
+ super();
+ this.catalogManager = catalogManager;
+ this.commonPartsURLConstructor(wsdlURL, configContext);
+ }
+
+ public WSDL4JWrapper(URL wsdlURL, ConfigurationContext configContext) throws FileNotFoundException,
+ UnknownHostException, ConnectException, IOException, WSDLException {
+ super();
+ this.commonPartsURLConstructor(wsdlURL, configContext);
+ }
+
+ private void commonPartsURLConstructor(URL wsdlURL, ConfigurationContext configContext) throws FileNotFoundException, UnknownHostException,
+ ConnectException, IOException, WSDLException {
this.configContext = configContext;
- // debugMemoryParms(configContext);
+ // debugMemoryParms(configContext);
if(log.isDebugEnabled()) {
log.debug("WSDL4JWrapper(URL,ConfigurationContext) - Looking for wsdl file on client: " + (wsdlURL != null ?
wsdlURL.getPath():null));
@@ -226,7 +248,7 @@
}
private URL getAbsoluteURL(ClassLoader classLoader, String filePath){
- URL url = classLoader.getResource(filePath);
+ URL url = classLoader.getResource(filePath);
if(url == null) {
if(log.isDebugEnabled()) {
log.debug("Could not get URL from classloader. Looking in a jar.");
@@ -265,20 +287,20 @@
private URL getURLFromJAR(URLClassLoader urlLoader, URL relativeURL) {
URL[] urlList = null;
- ResourceFinderFactory rff =(ResourceFinderFactory)MetadataFactoryRegistry.getFactory(ResourceFinderFactory.class);
+ ResourceFinderFactory rff =(ResourceFinderFactory)MetadataFactoryRegistry.getFactory(ResourceFinderFactory.class);
ResourceFinder cf = rff.getResourceFinder();
if (log.isDebugEnabled()) {
log.debug("ResourceFinderFactory: " + rff.getClass().getName());
log.debug("ResourceFinder: " + cf.getClass().getName());
}
-
- urlList = cf.getURLs(urlLoader);
- if(urlList == null){
- if(log.isDebugEnabled()){
- log.debug("No URL's found in URL ClassLoader");
- }
- throw ExceptionFactory.makeWebServiceException(Messages.getMessage("WSDL4JWrapperErr1"));
- }
+
+ urlList = cf.getURLs(urlLoader);
+ if(urlList == null){
+ if(log.isDebugEnabled()){
+ log.debug("No URL's found in URL ClassLoader");
+ }
+ throw ExceptionFactory.makeWebServiceException(Messages.getMessage("WSDL4JWrapperErr1"));
+ }
for (URL url : urlList) {
if ("file".equals(url.getProtocol())) {
@@ -338,12 +360,12 @@
throw (WSDLException)e.getException();
}
WSDLReaderConfigurator configurator = (WSDLReaderConfigurator) MetadataFactoryRegistry.
- getFactory(WSDLReaderConfigurator.class);
+ getFactory(WSDLReaderConfigurator.class);
if(configurator != null) {
- if(log.isDebugEnabled()) {
- log.debug("Calling configureReaderInstance with: " + configurator.getClass().getName());
- }
- configurator.configureReaderInstance(reader);
+ if(log.isDebugEnabled()) {
+ log.debug("Calling configureReaderInstance with: " + configurator.getClass().getName());
+ }
+ configurator.configureReaderInstance(reader);
}
return reader;
}
@@ -355,25 +377,38 @@
* @param Definition Definition for the WSDL
*/
public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition) throws WSDLException {
- this(wsdlURL, wsdlDefinition, null);
+ this(wsdlURL, wsdlDefinition, null, null);
}
-
+ /**
+ * Constructor
+ *
+ * @param URL The URL for the WSDL
+ * @param Definition Definition for the WSDL
+ * @param JAXWSCatalogManager Catalog Manager to use for locating external resources
+ */
+ public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition, JAXWSCatalogManager catalogManager) throws WSDLException {
+ this(wsdlURL, wsdlDefinition, null, catalogManager);
+ }
+
/**
* Constructor
*
* @param URL The URL for the WSDL
* @param Definition Definition for the WSDL
* @param ConfigurationContext to get parameters for WSDL building
+ * @param JAXWSCatalogManager Catalog Manager to use for locating external resources
*/
- public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition, ConfigurationContext configContext) throws WSDLException {
+ public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition, ConfigurationContext configContext,
+ JAXWSCatalogManager catalogManager) throws WSDLException {
super();
if (log.isDebugEnabled() ) { log.debug("WSDL4JWrapper(URL,Definition,ConfigContext) entry"); }
- this.configContext = configContext;
+ this.configContext = configContext;
+ this.catalogManager = catalogManager;
this.wsdlURL = wsdlURL;
if ((wsdlDefinition != null) && !(wsdlDefinition instanceof WSDLDefinitionWrapper)) {
- if (configContext != null) {
+ if (configContext != null) {
this.wsdlDefinition = new WSDLDefinitionWrapper(wsdlDefinition, wsdlURL, configContext.getAxisConfiguration() );
} else {
this.wsdlDefinition = new WSDLDefinitionWrapper(wsdlDefinition, wsdlURL);
@@ -418,7 +453,7 @@
if (wsdlDefinition == null) {
Definition def = loadDefinition();
if (def != null) {
- if (configContext != null) {
+ if (configContext != null) {
wsdlDefinition = new WSDLDefinitionWrapper(def, configContext.getAxisConfiguration() );
} else {
wsdlDefinition = new WSDLDefinitionWrapper(def, (AxisConfiguration)null);
@@ -458,11 +493,13 @@
try {
InputStream is = getInputStream(urlConn);
if(is != null) {
- final ModuleWSDLLocator locator = new ModuleWSDLLocator(wsdlExplicitURL, is,
- getThreadClassLoader());
+ if (catalogManager == null)
+ catalogManager = new OASISCatalogManager();
+ final CatalogWSDLLocator locator = new CatalogWSDLLocator(wsdlExplicitURL, is,
+ getThreadClassLoader(), catalogManager);
if(log.isDebugEnabled()) {
log.debug("Loading WSDL using ModuleWSDLLocator from base " +
- "location: " + wsdlExplicitURL);
+ "location: " + wsdlExplicitURL);
}
def = (Definition) AccessController.doPrivileged(new PrivilegedExceptionAction() {
public Object run() throws WSDLException {
@@ -475,8 +512,8 @@
catch(Exception e) {
if(log.isDebugEnabled()) {
log.debug("Using ModuleWSDLLocator was not successful for loading " +
- "WSDL due to the following error: " + e.toString() + ". The " +
- "WSDL will be read from the WSDL location: " + wsdlExplicitURL);
+ "WSDL due to the following error: " + e.toString() + ". The " +
+ "WSDL will be read from the WSDL location: " + wsdlExplicitURL);
}
}
}
@@ -501,7 +538,7 @@
catch(IOException ioe) {
if(log.isDebugEnabled()) {
log.debug("An error occurred while attempting to load the WSDL " +
- "file at the following location: " + wsdlExplicitURL);
+ "file at the following location: " + wsdlExplicitURL);
}
throw ExceptionFactory.makeWebServiceException(ioe);
}
@@ -723,20 +760,20 @@
* permissions if Java2 Security was enabled.
*/
private InputStream getInputStream(URLConnection urlCon) throws Exception {
- final URLConnection finalURLCon = urlCon;
- InputStream is = null;
- try {
- is = (InputStream) AccessController.doPrivileged(
- new PrivilegedExceptionAction() {
- public Object run() throws IOException {
- return finalURLCon.getInputStream();
- }
- });
- }
- catch(PrivilegedActionException e) {
- throw e.getException();
- }
- return is;
+ final URLConnection finalURLCon = urlCon;
+ InputStream is = null;
+ try {
+ is = (InputStream) AccessController.doPrivileged(
+ new PrivilegedExceptionAction() {
+ public Object run() throws IOException {
+ return finalURLCon.getInputStream();
+ }
+ });
+ }
+ catch(PrivilegedActionException e) {
+ throw e.getException();
+ }
+ return is;
}
private void debugMemoryParms(ConfigurationContext configContext) {
Modified: webservices/axis2/trunk/java/modules/parent/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/parent/pom.xml?rev=630959&r1=630958&r2=630959&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/parent/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/parent/pom.xml Mon Feb 25 11:09:01 2008
@@ -148,6 +148,7 @@
<xerces.version>2.8.1</xerces.version>
<xml_apis.version>1.3.04</xml_apis.version>
<xmlbeans.version>2.3.0</xmlbeans.version>
+ <xml_resolver.version>1.2</xml_resolver.version>
<xmlschema.version>SNAPSHOT</xmlschema.version>
<xmlunit.version>1.1</xmlunit.version>
<smack.version>3.0.4</smack.version>
@@ -550,6 +551,11 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>${xml_apis.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>xml-resolver</groupId>
+ <artifactId>xml-resolver</artifactId>
+ <version>${xml_resolver.version}</version>
</dependency>
<dependency>
<groupId>xalan</groupId>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org