summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-ws
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-30 10:06:46 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-06-30 10:06:46 +0000
commit93e8a5439342f2543907da37c33e38e0c37b00e0 (patch)
treee52f789a71501cdf82b01bb1296767877ecf86a6 /sca-java-2.x/trunk/modules/binding-ws
parentd298c1ad553a7a04f353052f1982f7f106c09503 (diff)
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-ws')
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java29
-rw-r--r--sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java99
2 files changed, 125 insertions, 3 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 c8ae5827a1..126847da59 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
@@ -214,5 +214,30 @@ public interface WebServiceBinding extends Binding {
* @param definition the generated WSDL definitions document
*/
void setGeneratedWSDLDocument(Definition definition);
-
-}
+
+
+ /*
+ * 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();
+}
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);
+ }
}