Author: slaws
Date: Thu Jul 1 13:42:49 2010
New Revision: 959658
URL: http://svn.apache.org/viewvc?rev=959658&view=rev
Log:
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.
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
Thu Jul 1 13:42:49 2010
@@ -333,6 +333,8 @@ public class WebServiceBindingProcessor
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()) {
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
Thu Jul 1 13:42:49 2010
@@ -137,4 +137,47 @@ public interface WSDLDefinition extends
* @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);
+
}
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
Thu Jul 1 13:42:49 2010
@@ -55,6 +55,13 @@ public class WSDLDefinitionImpl implemen
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 implemen
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;
+ }
}
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
Thu Jul 1 13:42:49 2010
@@ -215,6 +215,20 @@ public class WSDLDocumentProcessor imple
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;
}
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
Thu Jul 1 13:42:49 2010
@@ -257,6 +257,7 @@ public class WSDLInterfaceProcessor exte
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());
Modified:
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java?rev=959658&r1=959657&r2=959658&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
Thu Jul 1 13:42:49 2010
@@ -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 implement
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 implement
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) {