diff options
Diffstat (limited to 'branches/sca-java-1.3/modules')
12 files changed, 524 insertions, 299 deletions
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java index df7f339c62..1bfd20e937 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java @@ -27,6 +27,7 @@ import java.security.AccessController; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -38,6 +39,8 @@ import java.util.logging.Logger; import javax.wsdl.Definition; import javax.wsdl.Import; import javax.wsdl.Port; +import javax.wsdl.Types; +import javax.wsdl.extensions.UnknownExtensibilityElement; import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.extensions.soap12.SOAP12Address; import javax.xml.namespace.QName; @@ -85,6 +88,7 @@ import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.policy.PolicySet; @@ -98,12 +102,22 @@ import org.apache.tuscany.sca.runtime.ReferenceParameters; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.xsd.XSDefinition; +import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; import org.apache.ws.security.WSSecurityEngineResult; import org.apache.ws.security.handler.WSHandlerConstants; import org.apache.ws.security.handler.WSHandlerResult; import org.osoa.sca.ServiceRuntimeException; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + public class Axis2ServiceProvider { + public static final String IMPORT_TAG = "import"; + public static final String INCLUDE_TAG = "include"; private static final Logger logger = Logger.getLogger(Axis2ServiceProvider.class.getName()); @@ -129,6 +143,21 @@ public class Axis2ServiceProvider { private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory"; + //Schema element names + public static final String ELEM_SCHEMA = "schema"; + + //Schema URI + public static final String NS_URI_XSD_1999 = "http://www.w3.org/1999/XMLSchema"; + public static final String NS_URI_XSD_2000 = "http://www.w3.org/2000/10/XMLSchema"; + public static final String NS_URI_XSD_2001 = "http://www.w3.org/2001/XMLSchema"; + + //Schema QNames + public static final QName Q_ELEM_XSD_1999 = new QName(NS_URI_XSD_1999, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2000 = new QName(NS_URI_XSD_2000, ELEM_SCHEMA); + public static final QName Q_ELEM_XSD_2001 = new QName(NS_URI_XSD_2001, ELEM_SCHEMA); + public static final List<QName> XSD_QNAME_LIST = + Arrays.asList(new QName[] {Q_ELEM_XSD_1999, Q_ELEM_XSD_2000, Q_ELEM_XSD_2001}); + public Axis2ServiceProvider(RuntimeComponent component, AbstractContract contract, WebServiceBinding wsBinding, @@ -290,8 +319,7 @@ public class Axis2ServiceProvider { URI uriPath = new URI(endpointURL); String stringURIPath = uriPath.getPath(); - //[nash] Need a leading slash for WSDL imports to work with ?wsdl - /* + /* [nash] Need a leading slash for WSDL imports to work with ?wsdl // remove any "/" from the start of the path if (stringURIPath.startsWith("/")) { stringURIPath = stringURIPath.substring(1, stringURIPath.length()); @@ -425,6 +453,9 @@ public class Axis2ServiceProvider { } } + // Add schema information to the AxisService (needed for "?xsd=" support) + addSchemas(wsBinding.getWSDLDefinition(), axisService); + // Use the existing WSDL Parameter wsdlParam = new Parameter(WSDLConstants.WSDL_4_J_DEFINITION, null); wsdlParam.setValue(definition); @@ -432,6 +463,12 @@ public class Axis2ServiceProvider { Parameter userWSDL = new Parameter("useOriginalwsdl", "true"); axisService.addParameter(userWSDL); + // Modify schema imports and includes to add "servicename?xsd=" prefix. + // Axis2 does this for schema extensibility elements, but Tuscany has + // overriden the WSDl4J deserializer to create UnknownExtensibilityElement + // elements in place of these. + modifySchemaImportsAndIncludes(definition, name); + // Axis2 1.3 has a bug with returning incorrect values for the port // addresses. To work around this, compute the values here. Parameter modifyAddr = new Parameter("modifyUserWSDLPortAddress", "false"); @@ -447,6 +484,74 @@ public class Axis2ServiceProvider { return axisService; } + private void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) { + for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) { + axisService.addSchema(xsDef.getSchema()); + updateSchemaRefs(xsDef.getSchema(), axisService.getName()); + } + for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) { + addSchemas(impDef, axisService); + } + } + + private void updateSchemaRefs(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + String location = extSchema.getSchemaLocation(); + if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) { + extSchema.setSchemaLocation(name + "?xsd=" + location); + } + updateSchemaRefs(extSchema.getSchema(), name); + } + } + } + + private void modifySchemaImportsAndIncludes(Definition definition, String name){ + // adjust the schema locations in types section + Types types = definition.getTypes(); + if (types != null) { + for (Iterator iter = types.getExtensibilityElements().iterator(); iter.hasNext();) { + Object ext = iter.next(); + if (ext instanceof UnknownExtensibilityElement && + XSD_QNAME_LIST.contains(((UnknownExtensibilityElement)ext).getElementType())) { + changeLocations(((UnknownExtensibilityElement)ext).getElement(), name); + } + } + } + for (Iterator iter = definition.getImports().values().iterator(); iter.hasNext();) { + Vector values = (Vector)iter.next(); + for (Iterator valuesIter = values.iterator(); valuesIter.hasNext();) { + Import wsdlImport = (Import)valuesIter.next(); + modifySchemaImportsAndIncludes(wsdlImport.getDefinition(), name); + } + } + } + + private void changeLocations(Element element, String name) { + NodeList nodeList = element.getChildNodes(); + for (int i = 0; i < nodeList.getLength(); i++) { + String tagName = nodeList.item(i).getLocalName(); + if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) { + processImport(nodeList.item(i), name); + } + } + } + + private void processImport(Node importNode, String name) { + NamedNodeMap nodeMap = importNode.getAttributes(); + for (int i = 0; i < nodeMap.getLength(); i++) { + Node attribute = nodeMap.item(i); + if (attribute.getNodeName().equals("schemaLocation")) { + String location = attribute.getNodeValue(); + if (location.indexOf(":/") < 0 & location.indexOf("?xsd=") < 0) { + attribute.setNodeValue(name + "?xsd=" + location); + } + } + } + } + private String getPortAddress(Port port) { Object ext = port.getExtensibilityElements().get(0); if (ext instanceof SOAPAddress) { @@ -606,8 +711,8 @@ public class Axis2ServiceProvider { } private void createPolicyHandlers() throws IllegalAccessException, - InstantiationException, - ClassNotFoundException { + InstantiationException, + ClassNotFoundException { if (wsBinding instanceof PolicySetAttachPoint) { PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding; PolicyHandler policyHandler = null; diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java index 8e2e40c753..2342e7f6ef 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java @@ -58,6 +58,7 @@ import org.apache.axis2.wsdl.WSDLConstants; import org.apache.neethi.Policy; import org.apache.neethi.PolicyRegistry; import org.apache.ws.commons.schema.XmlSchema; +import org.apache.ws.commons.schema.XmlSchemaExternal; /** * A Tuscany specific Axis2 ListingAgent as the Axis2 one does not work @@ -86,6 +87,68 @@ public class TuscanyListingAgent extends ListingAgent { return serviceName; } + /** + * Override ?xsd processing so that WSDL documents with XSD imports + * and includes work correctly. When we move to Axis2 1.4, we may + * be able to use SchemaSupplier to do this in a cleaner way. + */ + @Override + public void processListService(HttpServletRequest req, + HttpServletResponse res) + throws IOException, ServletException { + + String url = req.getRequestURL().toString(); + String query = req.getQueryString(); + int xsd = query.indexOf("xsd"); + if (xsd >= 0) { + String serviceName = extractServiceName(url); + HashMap services = configContext.getAxisConfiguration().getServices(); + if ((services != null) && !services.isEmpty()) { + Object serviceObj = services.get(serviceName); + if (serviceObj != null) { + String xsds = req.getParameter("xsd"); + if (xsds != null && !"".equals(xsds)) { + // a schema name (perhaps with path) is present + AxisService axisService = (AxisService)serviceObj; + ArrayList schemas = axisService.getSchema(); + for (Object rootSchema : axisService.getSchema()) { + XmlSchema schema = getSchema(((XmlSchema)rootSchema), xsds); + if (schema != null) { + // found the schema + res.setContentType("text/xml"); + OutputStream out = res.getOutputStream(); + schema.write(new OutputStreamWriter(out, "UTF8")); + out.flush(); + out.close(); + return; + } + } + } + } + } + } + // in all other cases, delegate to the Axis2 code + super.processListService(req, res); + } + + private XmlSchema getSchema(XmlSchema parentSchema, String name) { + for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { + Object obj = iter.next(); + if (obj instanceof XmlSchemaExternal) { + XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; + if (extSchema.getSchemaLocation().endsWith(name)) { + return extSchema.getSchema(); + } else { + XmlSchema schema = getSchema(extSchema.getSchema(), name); + if (schema != null) { + return schema; + } + } + } + } + return null; + } + private String findAxisServiceName(String path) { HashMap services = configContext.getAxisConfiguration().getServices(); if (services == null) { @@ -130,106 +193,4 @@ public class TuscanyListingAgent extends ListingAgent { } } - private String extractHostAndPort(String filePart, boolean isHttp) { - int ipindex = filePart.indexOf("//"); - String ip = null; - if (ipindex >= 0) { - ip = filePart.substring(ipindex + 2, filePart.length()); - int seperatorIndex = ip.indexOf(":"); - int slashIndex = ip.indexOf("/"); - String port; - if (seperatorIndex >= 0) { - port = ip.substring(seperatorIndex + 1, slashIndex); - ip = ip.substring(0, seperatorIndex); - } else { - ip = ip.substring(0, slashIndex); - port = "80"; - } - if (isHttp) { - configContext.setProperty(RUNNING_PORT, port); - } - } - return ip; - } - - private Policy findPolicy(String id, AxisDescription des) { - - List policyElements = des.getPolicyInclude().getPolicyElements(); - PolicyRegistry registry = des.getPolicyInclude().getPolicyRegistry(); - - Object policyComponent; - - Policy policy = registry.lookup(id); - - if (policy != null) { - return policy; - } - - for (Iterator iterator = policyElements.iterator(); iterator.hasNext();) { - policyComponent = iterator.next(); - - if (policyComponent instanceof Policy) { - // policy found for the id - - if (id.equals(((Policy) policyComponent).getId())) { - return (Policy) policyComponent; - } - } - } - - AxisDescription child; - - for (Iterator iterator = des.getChildren(); iterator.hasNext();) { - child = (AxisDescription) iterator.next(); - policy = findPolicy(id, child); - - if (policy != null) { - return policy; - } - } - - return null; - } - - /** - * Hack to get ?wsdl working with soap 1.2 - * Fixed in Axis2 1.3 - */ - private void patchSOAP12Port(AxisService as) throws AxisFault { - Parameter wsld4jdefinition = as.getParameter(WSDLConstants.WSDL_4_J_DEFINITION); - Definition definition = (Definition) wsld4jdefinition.getValue(); - setPortAddress(definition, null, as); - } - - /** - * This is a copy of the AxisService setPortAddress patched to work with SOAP 1.2 Addresses - * Fixed in Axis2 1.3 - */ - private void setPortAddress(Definition definition, String requestIP, AxisService axisService) throws AxisFault { - Iterator serviceItr = definition.getServices().values().iterator(); - while (serviceItr.hasNext()) { - Service serviceElement = (Service) serviceItr.next(); - Iterator portItr = serviceElement.getPorts().values().iterator(); - while (portItr.hasNext()) { - Port port = (Port) portItr.next(); - List list = port.getExtensibilityElements(); - for (int i = 0; i < list.size(); i++) { - Object extensibilityEle = list.get(i); - String locationURI = null; - if (requestIP == null) { - locationURI = axisService.getEPRs()[0]; - } else { -// can't do this as the method's not visible, but Tuscany doesn't use this path anyway -// locationURI = axisService.getEPRs(requestIP)[0]); - } - if (extensibilityEle instanceof SOAPAddress) { - ((SOAPAddress) extensibilityEle).setLocationURI(locationURI); - } else if (extensibilityEle instanceof SOAP12Address) { - ((SOAP12Address) extensibilityEle).setLocationURI(locationURI); - } - } - } - } - } - } diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCaseFIXME.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java index 6ecba4782a..bfccb62cc7 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCaseFIXME.java +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java @@ -19,6 +19,10 @@ package org.apache.tuscany.sca.binding.ws.axis2.itests;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
import java.util.List;
import javax.wsdl.Definition;
@@ -39,7 +43,7 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; *
* @version $Rev$ $Date$
*/
-public class QuestionMarkWSDLImportTestCaseFIXME extends TestCase {
+public class QuestionMarkWSDLImportTestCase extends TestCase {
private SCADomain domain;
@@ -47,13 +51,21 @@ public class QuestionMarkWSDLImportTestCaseFIXME extends TestCase { * Tests ?wsdl works and returns the correct port endpoint from the WSDL
*/
public void testWSDLImportPortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8086/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
wsdlReader.setFeature("javax.wsdl.importDocuments", true);
Definition definition = wsdlReader.readWSDL("http://localhost:8086/AccountService?wsdl");
assertNotNull(definition);
- Service service = definition.getService(new QName("http://account2", "AccountService"));
+ Service service = definition.getService(new QName("http://account2/AccountService/$promoted$.ep1", "AccountService"));
Port port = service.getPort("AccountSoapPort");
String endpoint = getEndpoint(port);
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java index 6a0ab74135..aa54316660 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java @@ -19,6 +19,10 @@ package org.apache.tuscany.sca.binding.ws.axis2.itests;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
import java.util.List;
import javax.wsdl.Definition;
@@ -39,7 +43,7 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; *
* @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $
*/
-public class QuestionMarkWSDLIncludeTestCaseFIXME extends TestCase {
+public class QuestionMarkWSDLIncludeTestCase extends TestCase {
private SCADomain domain;
@@ -47,13 +51,21 @@ public class QuestionMarkWSDLIncludeTestCaseFIXME extends TestCase { * Tests ?wsdl works and returns the correct port endpoint from the WSDL
*/
public void testWSDLIncludePortEndpoint() throws Exception {
+ InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream();
+ BufferedReader br = new BufferedReader(new InputStreamReader(inp));
+ String line;
+ while((line = br.readLine()) != null) {
+ System.out.println(line);
+ }
+ br.close();
+
WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
wsdlReader.setFeature("javax.wsdl.verbose", false);
wsdlReader.setFeature("javax.wsdl.importDocuments", true);
Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl");
assertNotNull(definition);
- Service service = definition.getService(new QName("http://accounts", "AccountService"));
+ Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$.ep1", "AccountService"));
Port port = service.getPort("AccountSoapPort");
String endpoint = getEndpoint(port);
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java index 2b62c3b013..ac9da19119 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java @@ -45,7 +45,6 @@ import org.apache.tuscany.sca.host.embedded.SCADomain; */ public class QuestionMarkWSDLTestCase extends TestCase { - private static boolean newGenerator = true; private SCADomain domain; /** @@ -59,6 +58,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { System.out.println(line); } br.close(); + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose",false); wsdlReader.setFeature("javax.wsdl.importDocuments",true); @@ -85,16 +85,16 @@ public class QuestionMarkWSDLTestCase extends TestCase { System.out.println(line); } br.close(); + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); wsdlReader.setFeature("javax.wsdl.verbose",false); wsdlReader.setFeature("javax.wsdl.importDocuments",true); Definition definition = wsdlReader.readWSDL("http://localhost:8085/foo/bar?wsdl"); assertNotNull(definition); - Service service = definition.getService(new QName( - "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""), - newGenerator ? "HelloWorldService" : "HelloWorld")); - Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); + Service service = definition.getService(new QName("http://itests.axis2.ws.binding.sca.tuscany.apache.org/", + "HelloWorldService")); + Port port = service.getPort("HelloWorldPort"); String endpoint = getEndpoint(port); String ip = HttpUtils.getIpAddress(); diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd new file mode 100644 index 0000000000..ec67b84851 --- /dev/null +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:include schemaLocation="customerdata.xsd" />
+ <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd" />
+
+</xsd:schema>
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd new file mode 100644 index 0000000000..7c903c6394 --- /dev/null +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="CustomerProfileInfo">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string" />
+ <xsd:element name="lastName" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl new file mode 100644 index 0000000000..41a491361f --- /dev/null +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<wsdl:definitions targetNamespace="http://account3"
+ xmlns:tns="http://account3"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="questionmark-import-nested">
+
+ <wsdl:types>
+ <xsd:schema elementFormDefault="qualified"
+ targetNamespace="http://account3"
+ xmlns:account="http://accounts"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:import namespace="http://accounts" schemaLocation="customerdefs.xsd" />
+
+ <xsd:element name="getCustomerProfile">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="loginID" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:element name="getCustomerProfileResponse">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="customerProfile"
+ type="account:CustomerProfileData" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ </xsd:schema>
+ </wsdl:types>
+
+ <wsdl:message name="getCustomerProfileRequest">
+ <wsdl:part element="tns:getCustomerProfile" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:message name="getCustomerProfileResponse">
+ <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
+ </wsdl:message>
+
+ <wsdl:portType name="Account">
+ <wsdl:operation name="getCustomerProfile">
+ <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
+ <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
+ </wsdl:operation>
+ </wsdl:portType>
+
+</wsdl:definitions>
diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl index e57163e6c4..99a8c6d81d 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl @@ -1,90 +1,49 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<wsdl:definitions targetNamespace="http://account2"
- xmlns:tns="http://account2"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- name="questionmark-include">
-
- <wsdl:types>
- <xsd:schema elementFormDefault="qualified"
- targetNamespace="http://account2"
- xmlns:account="http://accounts"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xsd:import namespace="http://accounts" schemaLocation="customerdata.xsd" />
-
- <xsd:element name="getCustomerProfile">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="loginID" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="getCustomerProfileResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="customerProfile"
- type="account:CustomerProfileData" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- </xsd:schema>
- </wsdl:types>
-
- <wsdl:message name="getCustomerProfileRequest">
- <wsdl:part element="tns:getCustomerProfile" name="parameters" />
- </wsdl:message>
-
- <wsdl:message name="getCustomerProfileResponse">
- <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
- </wsdl:message>
-
- <wsdl:portType name="Account">
- <wsdl:operation name="getCustomerProfile">
- <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
- <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
- </wsdl:operation>
- </wsdl:portType>
-
- <wsdl:binding name="AccountSoapBinding" type="tns:Account">
- <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getCustomerProfile">
- <wsdlsoap:operation soapAction="" />
- <wsdl:input name="getCustomerProfileRequest">
- <wsdlsoap:body use="literal" />
- </wsdl:input>
- <wsdl:output name="getCustomerProfileResponse">
- <wsdlsoap:body use="literal" />
- </wsdl:output>
- </wsdl:operation>
-
- </wsdl:binding>
-
- <wsdl:service name="AccountService">
- <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort">
- <wsdlsoap:address location="http://localhost:8086/AccountService" />
- </wsdl:port>
- </wsdl:service>
-
-</wsdl:definitions>
+<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<wsdl:definitions targetNamespace="http://account2" + xmlns:tns="http://account2" + xmlns:account3="http://account3" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="questionmark-import"> + + <wsdl:import namespace="http://account3" location="/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl" /> + + <wsdl:binding name="AccountSoapBinding" type="account3:Account"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getCustomerProfile"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="getCustomerProfileRequest"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="getCustomerProfileResponse"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort"> + <wsdlsoap:address location="http://localhost:8086/AccountService" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl index 4000568977..80e4b62801 100644 --- a/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl +++ b/branches/sca-java-1.3/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl @@ -1,90 +1,94 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * 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.
--->
-<wsdl:definitions targetNamespace="http://accounts"
- xmlns:tns="http://accounts"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- name="questionmark-include">
-
- <wsdl:types>
- <xsd:schema elementFormDefault="qualified"
- targetNamespace="http://accounts"
- xmlns:account="http://accounts"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema">
-
- <xsd:include schemaLocation="customerdata.xsd" />
-
- <xsd:element name="getCustomerProfile">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="loginID" type="xsd:string" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="getCustomerProfileResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="customerProfile"
- type="account:CustomerProfileData" />
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- </xsd:schema>
- </wsdl:types>
-
- <wsdl:message name="getCustomerProfileRequest">
- <wsdl:part element="tns:getCustomerProfile" name="parameters" />
- </wsdl:message>
-
- <wsdl:message name="getCustomerProfileResponse">
- <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" />
- </wsdl:message>
-
- <wsdl:portType name="Account">
- <wsdl:operation name="getCustomerProfile">
- <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" />
- <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" />
- </wsdl:operation>
- </wsdl:portType>
-
- <wsdl:binding name="AccountSoapBinding" type="tns:Account">
- <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getCustomerProfile">
- <wsdlsoap:operation soapAction="" />
- <wsdl:input name="getCustomerProfileRequest">
- <wsdlsoap:body use="literal" />
- </wsdl:input>
- <wsdl:output name="getCustomerProfileResponse">
- <wsdlsoap:body use="literal" />
- </wsdl:output>
- </wsdl:operation>
-
- </wsdl:binding>
-
- <wsdl:service name="AccountService">
- <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort">
- <wsdlsoap:address location="http://localhost:8085/AccountService" />
- </wsdl:port>
- </wsdl:service>
-
-</wsdl:definitions>
+<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<wsdl:definitions targetNamespace="http://accounts" + xmlns:tns="http://accounts" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + name="questionmark-include"> + + <wsdl:types> + <xsd:schema elementFormDefault="qualified" + targetNamespace="http://accounts" + xmlns:account="http://accounts" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:include schemaLocation="/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd" /> + + <xsd:element name="getCustomerProfile"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="loginID" type="xsd:string" /> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:element name="getCustomerProfileResponse"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="customerProfile" + type="xsd:string" /> + <!-- + <xsd:element name="customerProfile" + type="account:CustomerProfileData" /> + --> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + </xsd:schema> + </wsdl:types> + + <wsdl:message name="getCustomerProfileRequest"> + <wsdl:part element="tns:getCustomerProfile" name="parameters" /> + </wsdl:message> + + <wsdl:message name="getCustomerProfileResponse"> + <wsdl:part element="tns:getCustomerProfileResponse" name="parameters" /> + </wsdl:message> + + <wsdl:portType name="Account"> + <wsdl:operation name="getCustomerProfile"> + <wsdl:input message="tns:getCustomerProfileRequest" name="getCustomerProfileRequest" /> + <wsdl:output message="tns:getCustomerProfileResponse" name="getCustomerProfileResponse" /> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="AccountSoapBinding" type="tns:Account"> + <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> + <wsdl:operation name="getCustomerProfile"> + <wsdlsoap:operation soapAction="" /> + <wsdl:input name="getCustomerProfileRequest"> + <wsdlsoap:body use="literal" /> + </wsdl:input> + <wsdl:output name="getCustomerProfileResponse"> + <wsdlsoap:body use="literal" /> + </wsdl:output> + </wsdl:operation> + + </wsdl:binding> + + <wsdl:service name="AccountService"> + <wsdl:port binding="tns:AccountSoapBinding" name="AccountSoapPort"> + <wsdlsoap:address location="http://localhost:8085/AccountService" /> + </wsdl:port> + </wsdl:service> + +</wsdl:definitions> diff --git a/branches/sca-java-1.3/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/branches/sca-java-1.3/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java index 9581f78980..0004774afa 100644 --- a/branches/sca-java-1.3/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java +++ b/branches/sca-java-1.3/modules/interface-wsdl-xml/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java @@ -282,6 +282,9 @@ public class WSDLModelResolver implements ModelResolver { // Lookup a definition for the given namespace String namespace = ((WSDLDefinition)unresolved).getNamespace(); + if (namespace == null) { + return modelClass.cast(unresolved); + } List<WSDLDefinition> list = map.get(namespace); WSDLDefinition resolved = aggregate(list); if (resolved != null && !resolved.isUnresolved()) { @@ -352,12 +355,40 @@ public class WSDLModelResolver implements ModelResolver { reader.setFeature("javax.wsdl.importDocuments", true); // FIXME: We need to decide if we should disable the import processing by WSDL4J // reader.setFeature("javax.wsdl.importDocuments", false); - reader.setExtensionRegistry(wsdlExtensionRegistry); + reader.setExtensionRegistry(wsdlExtensionRegistry); // use a custom registry WSDLLocatorImpl locator = new WSDLLocatorImpl(artifactURL, is); Definition definition = reader.readWSDL(locator); wsdlDef.setDefinition(definition); + // If this definition imports any definitions from other namespaces, + // set the correct WSDLDefinition import relationships. + for (Map.Entry<String, List<javax.wsdl.Import>> entry : + ((Map<String, List<javax.wsdl.Import>>)definition.getImports()).entrySet()) { + if (!entry.getKey().equals(definition.getTargetNamespace())) { + WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); + wsdlDefinition.setUnresolved(true); + wsdlDefinition.setNamespace(entry.getKey()); + WSDLDefinition resolved = resolveModel(WSDLDefinition.class, wsdlDefinition); + if (!resolved.isUnresolved()) { + for (javax.wsdl.Import imp : entry.getValue()) { + if (resolved.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) { + // this WSDLDefinition contains the imported document + wsdlDef.getImportedDefinitions().add(resolved); + } else { + // this is a facade, so look in its imported definitions + for (WSDLDefinition def : resolved.getImportedDefinitions()) { + if (def.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) { + wsdlDef.getImportedDefinitions().add(def); + break; + } + } + } + } + } + } + } + //Read inline schemas readInlineSchemas(wsdlDef, definition); } catch (WSDLException e) { @@ -427,6 +458,9 @@ public class WSDLModelResolver implements ModelResolver { contribution.getModelResolver().resolveModel(XSDefinition.class, xsDefinition); if (resolved != null && !resolved.isUnresolved()) { if (!wsdlDefinition.getXmlSchemas().contains(resolved)) { + // Don't add resolved because it may be an aggregate that + // contains more than we need. The resolver will have + // set the specific schema we need into unresolved. wsdlDefinition.getXmlSchemas().add(xsDefinition); } } diff --git a/branches/sca-java-1.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/branches/sca-java-1.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java index 42b34c7acc..652d9e8d83 100644 --- a/branches/sca-java-1.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java +++ b/branches/sca-java-1.3/modules/xsd-xml/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java @@ -87,11 +87,13 @@ public class XSDModelResolver implements ModelResolver { // Lookup a definition for the given namespace String namespace = definition.getNamespace(); List<XSDefinition> list = map.get(namespace); + XSDefinition modelXSD = null; if (list != null && definition.getDocument() != null) { // Set the document for the inline schema int index = list.indexOf(definition); - if (index != -1) { - list.get(index).setDocument(definition.getDocument()); + if (index != -1) { // a matching (not identical) document was found + modelXSD = list.get(index); + modelXSD.setDocument(definition.getDocument()); } } if (list == null && definition.getDocument() != null) { @@ -107,6 +109,14 @@ public class XSDModelResolver implements ModelResolver { throw new ContributionRuntimeException(e); } if (resolved != null && !resolved.isUnresolved()) { + if (definition.isUnresolved() && definition.getSchema() == null && modelXSD != null) { + // Update the unresolved model with schema information and mark it + // resolved. This information in the unresolved model is needed when + // this method is called by WSDLModelResolver.readInlineSchemas(). + definition.setSchema(modelXSD.getSchema()); + definition.setSchemaCollection(modelXSD.getSchemaCollection()); + definition.setUnresolved(false); + } return modelClass.cast(resolved); } @@ -221,7 +231,7 @@ public class XSDModelResolver implements ModelResolver { java.lang.String schemaLocation, java.lang.String baseUri) { try { - if (schemaLocation == null || schemaLocation.startsWith("/")) { + if (schemaLocation == null) { return null; } URL url = null; |