diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-01 13:42:49 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-01 13:42:49 +0000 |
commit | 266944c621775f642334bc2ec5bc4215d5a01c92 (patch) | |
tree | a638a51c401513e4a15d65654ebf6380ea9a7c1e /sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml | |
parent | b298381f6348640d572af8edaef5a42926caa5b1 (diff) |
TUSCANY-3604 add greater fidelity to the process of resolving WSDL by checking for required port type, binding, service as well as namespace during the resolution process.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@959658 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml')
3 files changed, 48 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java index 8291ef74ed..d2655bd88e 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java @@ -215,6 +215,20 @@ public class WSDLDocumentProcessor implements URLArtifactProcessor<WSDLDefinitio xsd.setSchema(null); wsdlDefinition.getXmlSchemas().add(xsd); } + + if (attr2.getValues().size() == 0){ + // if there are no schema defined add in the XSD schema + // so this at least gets resolved otherwise we'll get + // errors when trying to resolve part types that + // use primitive types + XSDefinition xsd = xsdFactory.createXSDefinition(); + xsd.setUnresolved(true); + xsd.setNamespace("http://www.w3.org/2001/XMLSchema"); + xsd.setUnresolved(false); + xsd.setSchema(null); + wsdlDefinition.getXmlSchemas().add(xsd); + } + return wsdlDefinition; } diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java index cbaa5cbd5e..4f838e92e8 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java @@ -257,6 +257,7 @@ public class WSDLInterfaceProcessor extends BaseStAXArtifactProcessor implements WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); wsdlDefinition.setUnresolved(true); wsdlDefinition.setNamespace(wsdlInterface.getName().getNamespaceURI()); + wsdlDefinition.setNameOfPortTypeToResolve(wsdlInterface.getName()); WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context); if (!resolved.isUnresolved()) { wsdlDefinition.setDefinition(resolved.getDefinition()); diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java index 33ebde869e..139a0ebd39 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java @@ -29,9 +29,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.wsdl.Binding; import javax.wsdl.Definition; import javax.wsdl.Operation; import javax.wsdl.PortType; +import javax.wsdl.Service; import javax.wsdl.Types; import javax.wsdl.WSDLException; import javax.wsdl.extensions.AttributeExtensible; @@ -50,6 +52,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; +import javax.xml.transform.stream.StreamSource; import org.apache.tuscany.sca.common.java.io.IOHelper; import org.apache.tuscany.sca.common.xml.XMLDocumentHelper; @@ -369,6 +372,30 @@ public class WSDLModelResolver implements ModelResolver { throw new RuntimeException(e); } if (resolved != null && !resolved.isUnresolved()) { + // check that the WSDL we just found has the requisite + // port type, binding and/or service. If not return + // the input WSDL to force the resolution process to continue + WSDLDefinition inputWSDL = (WSDLDefinition)unresolved; + WSDLDefinition outputWSDL = (WSDLDefinition)resolved; + + if (inputWSDL.getNameOfPortTypeToResolve() != null){ + if (outputWSDL.getWSDLObject(PortType.class, inputWSDL.getNameOfPortTypeToResolve()) == null){ + return modelClass.cast(unresolved); + } + } + + if (inputWSDL.getNameOfBindingToResolve() != null){ + if (outputWSDL.getWSDLObject(Binding.class, inputWSDL.getNameOfBindingToResolve()) == null){ + return modelClass.cast(unresolved); + } + } + + if (inputWSDL.getNameOfServiceToResolve() != null){ + if (outputWSDL.getWSDLObject(Service.class, inputWSDL.getNameOfServiceToResolve()) == null){ + return modelClass.cast(unresolved); + } + } + return modelClass.cast(resolved); } @@ -598,8 +625,12 @@ public class WSDLModelResolver implements ModelResolver { Map<String, String> wsdlImports = new HashMap<String, String>(); InputStream is = doc.openStream(); try { - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - XMLStreamReader reader = inputFactory.createXMLStreamReader(is); + // Set up a StreamSource for the composite file, since this has an associated URL that + // can be used by the parser to find references to other files such as DTDs + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + StreamSource wsdlSource = new StreamSource(is, doc.toString()); + XMLStreamReader reader = inputFactory.createXMLStreamReader(wsdlSource); + int eventType = reader.getEventType(); while (true) { if (eventType == XMLStreamConstants.START_ELEMENT) { |