From 93e8a5439342f2543907da37c33e38e0c37b00e0 Mon Sep 17 00:00:00 2001 From: slaws Date: Wed, 30 Jun 2010 10:06:46 +0000 Subject: TUSCANY-3614 - first pass at support for rpc/lit. Does the right sort of thing now but some of the code is in the wrong place so some refactoring still to do git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@959254 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/binding/ws/impl/WebServiceBindingImpl.java | 99 +++++++++++++++++++++- 1 file changed, 98 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl') 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 9fc60c2224..544e543c88 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 @@ -23,9 +23,15 @@ import java.util.ArrayList; import java.util.List; import javax.wsdl.Binding; +import javax.wsdl.BindingOperation; import javax.wsdl.Definition; +import javax.wsdl.Message; +import javax.wsdl.Part; import javax.wsdl.Port; import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPBinding; +import javax.wsdl.extensions.soap.SOAPBody; +import javax.wsdl.extensions.soap12.SOAP12Body; import javax.xml.namespace.QName; import org.apache.tuscany.sca.assembly.Extensible; @@ -71,6 +77,9 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi private InterfaceContract bindingInterfaceContract; private Element endPointReference; private Definition generatedWSDLDocument; + private boolean isDocumentStyle; + private boolean isLiteralEncoding; + private boolean isMessageWrapped; protected WebServiceBindingImpl() { } @@ -131,6 +140,8 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi if (binding == null) { if (getWSDLDefinition() != null && wsdlDefinition.getBinding() != null) { binding = wsdlDefinition.getBinding(); + setIsDocumentStyle(); + setIsLiteralEncoding(); } } return binding; @@ -191,6 +202,8 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setBinding(Binding binding) { this.binding = binding; + setIsDocumentStyle(); + setIsLiteralEncoding(); } public void setBindingName(QName bindingName) { @@ -293,6 +306,8 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setGeneratedWSDLDocument(Definition definition) { this.generatedWSDLDocument = definition; + setIsDocumentStyle(); + setIsLiteralEncoding(); } public QName getType() { @@ -318,5 +333,87 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi } public void setOperationSelector(OperationSelector operationSelector) { - } + } + + protected void setIsDocumentStyle() { + + if (binding == null){ + if (wsdlDefinition != null && wsdlDefinition.getDefinition() != null){ + Message firstMessage = (Message)wsdlDefinition.getDefinition().getMessages().values().iterator().next(); + Part firstPart = (Part)firstMessage.getParts().values().iterator().next(); + if (firstPart.getTypeName() != null){ + isDocumentStyle = false; + return; + } + } + + // default to document style + isDocumentStyle = true; + return; + } else { + for (Object ext : binding.getExtensibilityElements()){ + if (ext instanceof SOAPBinding){ + if (((SOAPBinding)ext).getStyle().equals("rpc")){ + isDocumentStyle = false; + return; + } else { + isDocumentStyle = true; + return; + } + } + } + isDocumentStyle = true; + return; + } + + } + + protected void setIsLiteralEncoding() { + + if (binding == null){ + // default to literal encoding + isLiteralEncoding = true; + return; + } else { + for(Object ext : ((BindingOperation)binding.getBindingOperations().get(0)).getBindingInput().getExtensibilityElements()){ + if (ext instanceof SOAPBody){ + if (((SOAPBody)ext).getUse().equals("literal")){ + isLiteralEncoding = true; + return; + } else { + isLiteralEncoding = false; + return; + } + } + } + isLiteralEncoding = true; + return; + } + } + + protected void setIsMessageWrapped() { + isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle(); + } + + public boolean isRpcEncoded() { + return (!isDocumentStyle) && (!isLiteralEncoding); + } + + public boolean isRpcLiteral() { + return (!isDocumentStyle) && (isLiteralEncoding); + } + + public boolean isDocEncoded() { + return (isDocumentStyle) && (!isLiteralEncoding); + } + + public boolean isDocLiteralUnwrapped() { + setIsMessageWrapped(); + return (isDocumentStyle) && (isLiteralEncoding) && (!isMessageWrapped); + } + + public boolean isDocLiteralWrapped() { + setIsMessageWrapped(); + return (isDocumentStyle) && (isLiteralEncoding) &&(isMessageWrapped); + } } -- cgit v1.2.3