summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-21 11:59:57 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-21 11:59:57 +0000
commitcc22c10642e9e496592f71aa496b75ff40dbe326 (patch)
tree2edff9a6128416088db1065b2637aeff6b71f82f /sca-java-2.x/trunk/modules/binding-ws/src
parent884a365865b7b6bc3dc0c01aae1af2d620586fb4 (diff)
BWS20006 - if a component reference binding.ws names a WSDL service with more than one port then pick the first port.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@956539 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws/src')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java36
1 files changed, 30 insertions, 6 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 68815fc157..170a5259f3 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
@@ -30,6 +30,8 @@ import javax.wsdl.Binding;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -348,14 +350,25 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
if (service != null) {
wsdlDefinition.setDefinition(service.getDefinition());
model.setService(service.getElement());
+
+ Port port = null;
if (model.getPortName() != null) {
- Port port = service.getElement().getPort(model.getPortName());
- if (port != null) {
- model.setPort(port);
- model.setBinding(port.getBinding());
- } else {
- warning(monitor, "WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName());
+ port = service.getElement().getPort(model.getPortName());
+ } else {
+ // BWS20006 - no port specified so pick the first one
+ port = (Port)service.getElement().getPorts().values().iterator().next();
+ }
+
+ if (port != null) {
+ model.setPort(port);
+ model.setBinding(port.getBinding());
+
+ // if no URI specified set it from the WSDL port location
+ if (model.getURI() == null){
+ model.setURI(getPortAddress(port));
}
+ } else {
+ error(monitor, "WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName());
}
} else {
error(monitor, "WsdlServiceDoesNotMatch", wsdlDefinition, model.getServiceName());
@@ -397,6 +410,17 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem
}
return portType;
}
+
+ public static String getPortAddress(Port port) {
+ Object ext = port.getExtensibilityElements().get(0);
+ if (ext instanceof SOAPAddress) {
+ return ((SOAPAddress)ext).getLocationURI();
+ }
+ if (ext instanceof SOAP12Address) {
+ return ((SOAP12Address)ext).getLocationURI();
+ }
+ return null;
+ }
public QName getArtifactType() {
return WebServiceConstants.BINDING_WS_QNAME;