From 266944c621775f642334bc2ec5bc4215d5a01c92 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 1 Jul 2010 13:42:49 +0000 Subject: 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 --- .../sca/interfacedef/wsdl/WSDLDefinition.java | 43 ++++++++++++++++++++++ .../interfacedef/wsdl/impl/WSDLDefinitionImpl.java | 32 +++++++++++++++- .../wsdl/xml/WSDLDocumentProcessor.java | 14 +++++++ .../wsdl/xml/WSDLInterfaceProcessor.java | 1 + .../interfacedef/wsdl/xml/WSDLModelResolver.java | 35 +++++++++++++++++- 5 files changed, 122 insertions(+), 3 deletions(-) (limited to 'sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org') diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java index 039e75f437..7497dd3c2f 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java @@ -137,4 +137,47 @@ public interface WSDLDefinition extends Base { * @param binding the WSDL binding */ void setBinding(Binding binding); + + /** + * Retrieves the name of the required port type used during the WSDL resolve process + * + * @return WSDL port type name + */ + QName getNameOfPortTypeToResolve(); + + /** + * Sets the name of the required port type used during the WSDL resolve process + * + * @param nameOfPortTypeToResolve + */ + void setNameOfPortTypeToResolve(QName nameOfPortTypeToResolve); + + /** + * Retrieves the name of the required binding used during the WSDL resolve process + * + * @return WSDL binding name + */ + QName getNameOfBindingToResolve(); + + /** + * Sets the name of the required binding used during the WSDL resolve process + * + * @param nameOfBindingToResolve + */ + void setNameOfBindingToResolve(QName nameOfBindingToResolve); + + /** + * Retrieves the name of the required service used during the WSDL resolve process + * + * @return WSDL service name + */ + QName getNameOfServiceToResolve(); + + /** + * Sets the name of the required service used during the WSDL resolve process + * + * @param nameOfBindingToResolve + */ + void setNameOfServiceToResolve(QName nameOfServiceToResolve); + } diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java index 82a7aa1200..45763d01b0 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java @@ -55,6 +55,13 @@ public class WSDLDefinitionImpl implements WSDLDefinition { private List schemas = new ArrayList(); private boolean unresolved; private Binding binding; + + // WSDL in the same namespace can appear in multiple contributions + // so we need to know which port type, binding and/or service we're looking for, + // as well as which namespace, when we're resolving WSDL + private QName nameOfPortTypeToResolve; + private QName nameOfBindingToResolve; + private QName nameOfServiceToResolve; protected WSDLDefinitionImpl() { } @@ -280,5 +287,28 @@ public class WSDLDefinitionImpl implements WSDLDefinition { public void setBinding(Binding binding) { this.binding = binding; } - + + public QName getNameOfPortTypeToResolve() { + return nameOfPortTypeToResolve; + } + + public void setNameOfPortTypeToResolve(QName nameOfPortTypeToResolve) { + this.nameOfPortTypeToResolve = nameOfPortTypeToResolve; + } + + public QName getNameOfBindingToResolve() { + return nameOfBindingToResolve; + } + + public void setNameOfBindingToResolve(QName nameOfBindingToResolve) { + this.nameOfBindingToResolve = nameOfBindingToResolve; + } + + public QName getNameOfServiceToResolve() { + return nameOfServiceToResolve; + } + + public void setNameOfServiceToResolve(QName nameOfServiceToResolve) { + this.nameOfServiceToResolve = nameOfServiceToResolve; + } } 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 wsdlImports = new HashMap(); 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) { -- cgit v1.2.3