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=584248&r1=584247&r2=584248&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 Fri Oct 12 12:53:43 2007 @@ -25,6 +25,7 @@ import org.apache.axis2.metadata.factory.ResourceFinderFactory; import org.apache.axis2.metadata.registry.MetadataFactoryRegistry; import org.apache.axis2.metadata.resource.ResourceFinder; +import org.apache.axis2.wsdl.util.WSDLDefinitionWrapper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -63,8 +64,11 @@ public class WSDL4JWrapper implements WSDLWrapper { private static final Log log = LogFactory.getLog(WSDL4JWrapper.class); - private Definition wsdlDefinition = null; + + private WSDLDefinitionWrapper wsdlDefinition = null; + private URL wsdlURL; + private String wsdlExplicitURL; public WSDL4JWrapper(URL wsdlURL) throws FileNotFoundException, UnknownHostException, ConnectException, IOException, WSDLException { @@ -153,23 +157,8 @@ if(is != null) { is.close(); } - final String explicitWsdl = urlCon.getURL().toString(); - try { - wsdlDefinition = (Definition)AccessController.doPrivileged( - new PrivilegedExceptionAction() { - public Object run() throws WSDLException { - WSDLReader reader = getWSDLReader(); - return reader.readWSDL(explicitWsdl); - } - } - ); - } catch (PrivilegedActionException e) { - if (log.isDebugEnabled()) { - log.debug("Exception thrown from AccessController: " + e); - } - throw ExceptionFactory.makeWebServiceException(e.getException()); - } - + this.wsdlExplicitURL = urlCon.getURL().toString(); + getDefinition(); } catch (FileNotFoundException ex) { throw ex; } catch (UnknownHostException ex) { @@ -272,18 +261,99 @@ public WSDL4JWrapper(URL wsdlURL, Definition wsdlDefinition) throws WSDLException { super(); this.wsdlURL = wsdlURL; - this.wsdlDefinition = wsdlDefinition; + if ((wsdlDefinition != null) && !(wsdlDefinition instanceof WSDLDefinitionWrapper)) { + this.wsdlDefinition = new WSDLDefinitionWrapper(wsdlDefinition, wsdlURL); + } else { + this.wsdlDefinition = (WSDLDefinitionWrapper) wsdlDefinition; + } + } + + + public WSDL4JWrapper(Definition wsdlDefinition) throws WSDLException { + super(); + if ((wsdlDefinition != null) && !(wsdlDefinition instanceof WSDLDefinitionWrapper)) { + this.wsdlDefinition = new WSDLDefinitionWrapper(wsdlDefinition); + } else { + this.wsdlDefinition = (WSDLDefinitionWrapper) wsdlDefinition; + } + if (this.wsdlDefinition != null) { + String baseURI = wsdlDefinition.getDocumentBaseURI(); + try { + wsdlURL = new URL(baseURI); + } catch (Exception ex) { + // just absorb the error + } + } } + //TODO: Perform validations for each method to check for null parameters on QName. + /* + * Returns a wrapped WSDL4J wSDL definition + */ public Definition getDefinition() { + if (wsdlDefinition == null) { + Definition def = loadDefinition(); + if (def != null) { + wsdlDefinition = new WSDLDefinitionWrapper(def); + } + } return wsdlDefinition; } + /* + * Returns an unwrapped WSDL4J wSDL definition + */ + public Definition getUnwrappedDefinition() { + Definition def; + if (wsdlDefinition == null) { + def = loadDefinition(); + } else if (wsdlDefinition instanceof WSDLDefinitionWrapper) { + def = wsdlDefinition.getUnwrappedDefinition(); + } else { + def = wsdlDefinition; + } + return def; + } + + + /* + * Load a WSDL4J WSDL definition from a URL + */ + public Definition loadDefinition() { + + Definition def = null; + + if (wsdlExplicitURL != null) { + try { + def = (Definition) AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws WSDLException { + WSDLReader reader = getWSDLReader(); + return reader.readWSDL(wsdlExplicitURL); + } + }); + } catch (PrivilegedActionException e) { + if (log.isDebugEnabled()) { + log.debug("Exception thrown from AccessController: " + e); + } + throw ExceptionFactory.makeWebServiceException(e.getException()); + } + } + + + if (log.isDebugEnabled()) { + if (def != null) { + log.debug("loadDefinition() returning a NON-NULL definition"); + } else { + log.debug("loadDefinition() returning a NULL definition"); + } + } + + return def; + } public Binding getFirstPortBinding(QName serviceQname) { - // TODO Auto-generated method stub Service service = getService(serviceQname); if (service == null) { return null; @@ -326,7 +396,6 @@ } public ArrayList getPortBinding(QName serviceQname) { - // TODO Auto-generated method stub Map map = this.getService(serviceQname).getPorts(); if (map == null || map.isEmpty()) { return null; @@ -375,16 +444,19 @@ } public Service getService(QName serviceQname) { - // TODO Auto-generated method stub if (serviceQname == null) { return null; } - return wsdlDefinition.getService(serviceQname); + Definition def = getDefinition(); + if (def != null) { + return def.getService(serviceQname); + } else { + return null; + } } public String getSOAPAction(QName serviceQname) { - // TODO Auto-generated method stub Binding binding = getFirstPortBinding(serviceQname); if (binding == null) { return null; @@ -405,7 +477,6 @@ } public String getSOAPAction(QName serviceQname, QName portQname) { - // TODO Auto-generated method stub Port port = getPort(serviceQname, portQname); if (port == null) { return null; @@ -461,7 +532,6 @@ } public URL getWSDLLocation() { - // TODO Auto-generated method stub return this.wsdlURL; } @@ -472,8 +542,12 @@ } public String getTargetNamespace() { - // TODO Auto-generated method stub - return wsdlDefinition.getTargetNamespace(); + Definition def = getDefinition(); + if (def != null) { + return def.getTargetNamespace(); + } else { + return null; + } } /**
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDLWrapper.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDLWrapper.java?rev=584248&r1=584247&r2=584248&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDLWrapper.java (original) +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/util/WSDLWrapper.java Fri Oct 12 12:53:43 2007 @@ -65,4 +65,6 @@ public String getTargetNamespace(); public Definition getDefinition(); + + public Definition getUnwrappedDefinition(); } Modified: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java?rev=584248&r1=584247&r2=584248&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java (original) +++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/DescriptionTestUtils.java Fri Oct 12 12:53:43 2007 @@ -61,6 +61,7 @@ WSDLFactory factory = WSDLFactory.newInstance(); WSDLReader reader = factory.newWSDLReader(); wsdlDefinition = reader.readWSDL(wsdlURL.toString()); + wsdlDefinition.setDocumentBaseURI(wsdlURL.toString()); } catch (Exception e) { System.out.println( Modified: webservices/axis2/trunk/java/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java?rev=584248&r1=584247&r2=584248&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java (original) +++ webservices/axis2/trunk/java/modules/tool/axis2-eclipse-codegen-plugin/src/main/java/org/apache/axis2/tool/codegen/WSDL2JavaGenerator.java Fri Oct 12 12:53:43 2007 @@ -201,6 +201,10 @@ WSDL11ToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(url.openConnection().getInputStream()); + // Set the URI of the base document for the Definition. + // Note that this is the URI of the base document, not the imports. + builder.setDocumentBaseUri(url.toString()); + builder.setBaseUri(getBaseUri(wsdlURI)); builder.setCodegen(true); return builder.populateService(); Modified: webservices/axis2/trunk/java/modules/tool/axis2-idea-plugin/src/main/java/org/apache/axis2/tools/bean/CodegenBean.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/tool/axis2-idea-plugin/src/main/java/org/apache/axis2/tools/bean/CodegenBean.java?rev=584248&r1=584247&r2=584248&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/tool/axis2-idea-plugin/src/main/java/org/apache/axis2/tools/bean/CodegenBean.java (original) +++ webservices/axis2/trunk/java/modules/tool/axis2-idea-plugin/src/main/java/org/apache/axis2/tools/bean/CodegenBean.java Fri Oct 12 12:53:43 2007 @@ -287,6 +287,7 @@ WSDL11ToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(url.openConnection().getInputStream()); + builder.setDocumentBaseUri(url.toString()); builder.setBaseUri(getBaseUri(wsdlURI)); builder.setCodegen(true); return builder.populateService(); @@ -407,6 +408,9 @@ WSDLReader reader = WSDLFactory.newInstance().newWSDLReader(); wsdlDefinition = reader.readWSDL(WSDLFileName) ; + if (wsdlDefinition != null) { + wsdlDefinition.setDocumentBaseURI(WSDLFileName); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]