diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-02 15:12:28 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-02 15:12:28 +0000 |
commit | fccdd6a87c4e9961153eb52e9b2b9f614ebb9724 (patch) | |
tree | a8a4640744c6babc2f54751ecd4e561c9b7b73c6 /sca-java-2.x/trunk/modules/binding-ws/src | |
parent | 8a38be79d254e187d4313fe68692551b2f735e10 (diff) |
More changes to fix binding.s otests. Also change binding.ws model getter/setter to make it more explicit which of the WSDLs it stores are user defined.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@960020 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws/src')
4 files changed, 148 insertions, 20 deletions
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} |