diff options
6 files changed, 124 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java index 7231925787..ee03aeee21 100644 --- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java +++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java @@ -333,6 +333,8 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition(); wsdlDefinition.setUnresolved(true); wsdlDefinition.setNamespace(model.getNamespace()); + wsdlDefinition.setNameOfBindingToResolve(model.getBindingName()); + wsdlDefinition.setNameOfServiceToResolve(model.getServiceName()); WSDLDefinition resolved = resolver.resolveModel(WSDLDefinition.class, wsdlDefinition, context); if (!resolved.isUnresolved()) { 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<XSDefinition> schemas = new ArrayList<XSDefinition>(); 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<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) { |