diff options
Diffstat (limited to '')
10 files changed, 156 insertions, 28 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java index 08c140c74c..a8d35c3381 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2EngineIntegration.java @@ -278,7 +278,7 @@ public class Axis2EngineIntegration { } // Add schema information to the AxisService (needed for "?xsd=" support) - addSchemas(wsBinding.getWSDLDefinition(), axisService); + addSchemas(wsBinding.getUserSpecifiedWSDLDefinition(), axisService); // Use the existing WSDL Parameter wsdlParam = new Parameter("wsdl4jDefinition", null); diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java index 4d71e97568..1532aa6a65 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java @@ -162,7 +162,7 @@ public class Axis2ReferenceBindingInvoker implements Invoker { } if (wrapperNamespace == null){ - wrapperNamespace = wsBinding.getWSDLDefinition().getNamespace(); + wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace(); } QName operationQName = new QName(wrapperNamespace, diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java index a09d18c1dd..59645ef679 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java @@ -203,7 +203,7 @@ public class TuscanyServiceProvider { }
if (wrapperNamespace == null){
- wrapperNamespace = wsBinding.getWSDLDefinition().getNamespace();
+ wrapperNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getNamespace();
}
QName operationResponseQName = new QName(wrapperNamespace,
diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java index b8efc2dcdd..516ca62c11 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws-ri/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/ri/JAXWSServiceBindingProvider.java @@ -81,7 +81,7 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider { // sometimes getService().getQName returns a QName namespace that doesn't match the WSDL // sometimes getNamespace() returns null // So here we delve directly into the WSDL4J model as the Tuscany model isn't up to date - String targetNamespace = wsBinding.getWSDLDefinition().getDefinition().getTargetNamespace(); + String targetNamespace = wsBinding.getUserSpecifiedWSDLDefinition().getDefinition().getTargetNamespace(); //set up WSDL for Provider List<Source> metadata = new ArrayList<Source>(); @@ -94,7 +94,7 @@ public class JAXWSServiceBindingProvider implements ServiceBindingProvider { ByteArrayOutputStream outStream = new ByteArrayOutputStream(); try { WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter(); - writer.writeWSDL(wsBinding.getWSDLDefinition().getDefinition(), outStream); + writer.writeWSDL(wsBinding.getUserSpecifiedWSDLDefinition().getDefinition(), outStream); } catch (Exception ex){ ex.printStackTrace(); } diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java index 4d67f8de3f..bf573f9970 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/src/main/java/org/apache/tuscany/sca/binding/ws/jaxws/JAXWSBindingInvoker.java @@ -117,8 +117,8 @@ public class JAXWSBindingInvoker implements Invoker, DataExchangeSemantics { wsdlLocation = new URL(wsBinding.getGeneratedWSDLDocument().getDocumentBaseURI()); } catch (Exception e) { try { - if (wsBinding.getWSDLDefinition().getLocation() != null) { - wsdlLocation = wsBinding.getWSDLDefinition().getLocation().toURL(); + if (wsBinding.getUserSpecifiedWSDLDefinition().getLocation() != null) { + wsdlLocation = wsBinding.getUserSpecifiedWSDLDefinition().getLocation().toURL(); } } catch (MalformedURLException e1) { // TODO Auto-generated catch block diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java index 4ecde7f4d3..3bc784401a 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java @@ -137,7 +137,7 @@ public class WSDLServiceGenerator { String contractName = contract.getName(); List<Port> ports = new ArrayList<Port>(); - WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition(); + WSDLDefinition wsdlDefinition = wsBinding.getUserSpecifiedWSDLDefinition(); if (wsdlDefinition == null) { error(monitor, "NoWsdlInterface", wsBinding, component.getName(), contract.getName()); return null; diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java index 126847da59..22ea63bd89 100644 --- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java +++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java @@ -154,18 +154,24 @@ public interface WebServiceBinding extends Binding { void setBinding(javax.wsdl.Binding binding); /** - * Returns the WSDL definition. + * Returns the WSDL definition that was specified by the + * user either via and interface.wsdl or via a wsdlElement + * on the binding. This may be empty if no WSDL was specified + * explicitly in which case the generated WSDL should contain + * a full WSDL description + * * @return the WSDL definition */ - WSDLDefinition getWSDLDefinition(); + WSDLDefinition getUserSpecifiedWSDLDefinition(); /** * Sets the WSDL definition if one was specified by the user in the - * composite file + * composite file either via and interface.wsdl or via a wsdlElement + * on the binding * * @param wsdlDefinition the WSDL definition */ - void setDefinition(WSDLDefinition wsdlDefinition); + void setUserSpecifiedWSDLDefinition(WSDLDefinition wsdlDefinition); /** * Returns the WSDL namespace. @@ -215,29 +221,51 @@ public interface WebServiceBinding extends Binding { */ void setGeneratedWSDLDocument(Definition definition); + /** + * Returns string from the WSDL that represents the SOAP binding transport + */ + String getBindingTransport(); - /* + /** * Returns true if the WSDL style is rpc/encoded */ boolean isRpcEncoded(); - /* + /** * Returns true if the WSDL style is rpc/literal */ boolean isRpcLiteral(); - /* + /** * Returns true if the WSDL style is doc/encoded */ boolean isDocEncoded(); - /* + /** * Returns true is the WSDL style is doc/literal */ boolean isDocLiteralUnwrapped(); - /* + /** * Returns true if the WSDL style is doc/literal/wrapped */ boolean isDocLiteralWrapped(); + + /** + * Returns true if the WSDL style is doc/literal + * and the mapping to the interface is bare + */ + boolean isDocLiteralBare(); + + /** + * Returns true is the WSBinding is configured, via WSDL, + * to use an HTTP transport + */ + boolean isHTTPTransport(); + + /** + * Returns true is the WSBinding is configured, via WSDL, + * to use a JMS transport + */ + boolean isJMSTransport(); } diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java index 544e543c88..9cda2978d3 100644 --- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java +++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java @@ -138,10 +138,9 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public Binding getBinding() { if (binding == null) { - if (getWSDLDefinition() != null && wsdlDefinition.getBinding() != null) { + if (getUserSpecifiedWSDLDefinition() != null && wsdlDefinition.getBinding() != null) { binding = wsdlDefinition.getBinding(); - setIsDocumentStyle(); - setIsLiteralEncoding(); + determineWSDLCharacteristics(); } } return binding; @@ -202,8 +201,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setBinding(Binding binding) { this.binding = binding; - setIsDocumentStyle(); - setIsLiteralEncoding(); + determineWSDLCharacteristics(); } public void setBindingName(QName bindingName) { @@ -246,7 +244,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi this.serviceName = serviceName; } - public WSDLDefinition getWSDLDefinition() { + public WSDLDefinition getUserSpecifiedWSDLDefinition() { if (wsdlDefinition == null) { Interface iface = bindingInterfaceContract.getInterface(); if (iface instanceof WSDLInterface) { @@ -256,7 +254,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi return wsdlDefinition; } - public void setDefinition(WSDLDefinition wsdlDefinition) { + public void setUserSpecifiedWSDLDefinition(WSDLDefinition wsdlDefinition) { this.wsdlDefinition = wsdlDefinition; } @@ -306,8 +304,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setGeneratedWSDLDocument(Definition definition) { this.generatedWSDLDocument = definition; - setIsDocumentStyle(); - setIsLiteralEncoding(); + determineWSDLCharacteristics(); } public QName getType() { @@ -335,6 +332,16 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setOperationSelector(OperationSelector operationSelector) { } + /** + * Some items get calculated and cached as they are used are runtime + * to decide what message processing is required + */ + protected void determineWSDLCharacteristics() { + setIsDocumentStyle(); + setIsLiteralEncoding(); + setIsMessageWrapped(); + } + protected void setIsDocumentStyle() { if (binding == null){ @@ -392,7 +399,9 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi } protected void setIsMessageWrapped() { - isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle(); + if (getBindingInterfaceContract() != null){ + isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle(); + } } public boolean isRpcEncoded() { @@ -416,4 +425,30 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi setIsMessageWrapped(); return (isDocumentStyle) && (isLiteralEncoding) &&(isMessageWrapped); } + + public boolean isDocLiteralBare() { + setIsMessageWrapped(); + return (isDocumentStyle) && (isLiteralEncoding); + } + + public boolean isHTTPTransport() { + return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/http"); + } + + public boolean isJMSTransport() { + return getBindingTransport().equals("http://schemas.xmlsoap.org/soap/jms"); + } + + public String getBindingTransport() { + if (binding != null){ + for (Object ext : binding.getExtensibilityElements()){ + if (ext instanceof SOAPBinding){ + return ((SOAPBinding)ext).getTransportURI(); + } + } + } + + // if no binding is explicitly specified by the user then default to http + return "http://schemas.xmlsoap.org/soap/http"; + } } 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 ee03aeee21..0b81dbbb5a 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 @@ -24,6 +24,8 @@ import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import javax.wsdl.Binding; @@ -31,6 +33,7 @@ import javax.wsdl.Port; import javax.wsdl.PortType; import javax.wsdl.Service; import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap12.SOAP12Address; import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamException; @@ -132,6 +135,10 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem if (name != null) { wsBinding.setName(name); } + + // a collection of endpoint specifications so that we can test that + // only one is present + List<String> endpointSpecifications = new ArrayList<String>(); // Read URI String uri = getURIString(reader, URI); @@ -149,6 +156,7 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem } catch (URISyntaxException ex){ error(monitor, "InvalidURISyntax", reader, ex.getMessage()); } + endpointSpecifications.add("uri"); } // BWS20020 @@ -182,6 +190,8 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem // Read a wsdl.service localName = localName.substring("wsdl.service(".length(), localName.length() - 1); wsBinding.setServiceName(new QName(namespace, localName)); + + endpointSpecifications.add("#wsdl.service"); } else if (localName.startsWith("wsdl.port")) { @@ -195,6 +205,8 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem wsBinding.setServiceName(new QName(namespace, localName.substring(0, s))); wsBinding.setPortName(localName.substring(s + 1)); } + + endpointSpecifications.add("#wsdl.port"); } else if (localName.startsWith("wsdl.endpoint")) { // Read a wsdl.endpoint @@ -207,6 +219,7 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem wsBinding.setServiceName(new QName(namespace, localName.substring(0, s))); wsBinding.setEndpointName(localName.substring(s + 1)); } + } else if (localName.startsWith("wsdl.binding")) { // Read a wsdl.binding @@ -237,7 +250,9 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem error(monitor, "MustUseWsdlBinding", reader, wsdlElement); throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference"); } + wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader)); + endpointSpecifications.add("wsa:EndpointReference"); } } break; @@ -248,6 +263,11 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem break; } } + + if (endpointSpecifications.size() > 1){ + error(monitor, "MultipleEndpointsSpecified", reader, endpointSpecifications.toString() ); + } + return wsBinding; } @@ -344,7 +364,7 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem wsdlDefinition.getImportedDefinitions().addAll(resolved.getImportedDefinitions()); wsdlDefinition.getXmlSchemas().addAll(resolved.getXmlSchemas()); wsdlDefinition.setUnresolved(false); - model.setDefinition(wsdlDefinition); + model.setUserSpecifiedWSDLDefinition(wsdlDefinition); if (model.getBindingName() != null) { WSDLObject<Binding> binding = wsdlDefinition.getWSDLObject(Binding.class, model.getBindingName()); if (binding != null) { @@ -396,11 +416,54 @@ public class WebServiceBindingProcessor extends BaseStAXArtifactProcessor implem interfaceContract.setInterface(wsdlInterface); model.setBindingInterfaceContract(interfaceContract); } + + validateWSDL(context, model); + } else { + if (model.getBindingName() != null){ + error(monitor, "WsdlBindingDoesNotMatch", model, model.getBindingName()); + } + + if (model.getServiceName() != null){ + error(monitor, "WsdlServiceDoesNotMatch", model, model.getServiceName()); + } } policyProcessor.resolvePolicies(model, resolver, context); } + private void validateWSDL(ProcessorContext context, WebServiceBinding model) { + WSDLDefinition wsdlDefinition = model.getUserSpecifiedWSDLDefinition(); + + Port port = model.getPort(); + + if (port != null){ + validateWSDLPort(context, model, port); + } + + Binding binding = model.getBinding(); + + if (binding != null){ + validateWSDLBinding(context, model, binding); + } + } + + private void validateWSDLPort(ProcessorContext context, WebServiceBinding model, Port port){ + + validateWSDLBinding(context, model, port.getBinding()); + + } + + private void validateWSDLBinding(ProcessorContext context, WebServiceBinding model, Binding binding){ + // BWS20005 & BWS20010 + // Check that the WSDL binding is of a supported type + if (!model.isHTTPTransport() && !model.isJMSTransport()){ + error(context.getMonitor(), + "InvalidWSDLBindingTransport", + model, + model.getBindingTransport()); + } + } + private PortType getPortType(WebServiceBinding model) { PortType portType = null; if (model.getPort() != null) { diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties b/sca-java-2.x/trunk/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties index 215220a72d..b5ede881e7 100644 --- a/sca-java-2.x/trunk/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties +++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties @@ -29,6 +29,8 @@ URINotAbsolute = [BWS20001] The URI value for binding.ws on an SCA reference mus InvalidURISyntax = The URI value {0} found on binding.ws has invalid syntax WSDLServiceOnService = [BWS20003] The wsdlElement attribute of a binding.ws on an SCA service must not specify the wsdl.service form of URI. The following URI was found {0} URIFoundForServiceCallback = [BWS20020] For the callback element of an SCA service, the binding must not specify an endpoint address URI or a WS-Addressing wsa:EndpointReference +InvalidWSDLBindingTransport = [BWS20005][BWS20010] The WSDL binding transport {0} is not supported by Tuscany +MultipleEndpointsSpecified = [BWS20019] with binding.ws you can only specify one of url, wsa:EndpointReference, #wsdl.service or #wsdl.port. The following were found {0} |