Author: slaws
Date: Wed Jun 30 10:06:46 2010
New Revision: 959254
URL: http://svn.apache.org/viewvc?rev=959254&view=rev
Log:
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
Modified:
tuscany/sca-java-2.x/trunk/itest/ws/pom.xml
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
Modified: tuscany/sca-java-2.x/trunk/itest/ws/pom.xml
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/ws/pom.xml?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/ws/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/itest/ws/pom.xml Wed Jun 30 10:06:46 2010
@@ -51,6 +51,7 @@
<module>contribution-callback-fullspec</module>
<module>contribution-callback-promotion</module>
<module>contribution-doc-lit-wrapped</module>
+ <module>contribution-rpc-lit</module>
<module>external-client</module>
<module>external-service</module>
<module>launcher-axis2</module>
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingInvoker.java
Wed Jun 30 10:06:46 2010
@@ -21,14 +21,20 @@ package org.apache.tuscany.sca.binding.w
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
+import javax.wsdl.BindingOperation;
import javax.wsdl.Operation;
import javax.wsdl.PortType;
+import javax.wsdl.extensions.soap.SOAPBinding;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNode;
import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPEnvelope;
@@ -99,6 +105,15 @@ public class Axis2ReferenceBindingInvoke
final OperationClient operationClient = createOperationClient(msg);
msg.setBindingContext(operationClient);
msg =
endpointReference.getBindingInvocationChain().getHeadInvoker().invoke(msg);
+
+ if (wsBinding.isRpcLiteral()){
+ // remove the wrapping element containing
+ // the operation response name
+ OMElement operationResponseElement = msg.getBody();
+ if (operationResponseElement != null){
+
msg.setBody(operationResponseElement.getChildElements().next());
+ }
+ }
} catch (AxisFault e) {
if (e.getDetail() != null ) {
@@ -120,15 +135,74 @@ public class Axis2ReferenceBindingInvoke
SOAPEnvelope env = soapFactory.getDefaultEnvelope();
Object[] args = (Object[])msg.getBody();
if (args != null && args.length > 0) {
- SOAPBody body = env.getBody();
- for (Object bc : args) {
- if (bc instanceof OMElement) {
- body.addChild((OMElement)bc);
- } else {
- throw new IllegalArgumentException( "Can't handle mixed
payloads between OMElements and other types.");
+
+ if (wsBinding.isRpcLiteral()){
+ // create the wrapping element containing
+ // the operation name
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ String wrapperNamespace = null;
+
+ // the rpc style creates a wrapper with a namespace where the
namespace is
+ // defined on the wsdl binding operation. If no binding is
provided by the
+ // user then default to the namespace of the WSDL itself.
+ if (wsBinding.getBinding() != null){
+ Iterator iter =
wsBinding.getBinding().getBindingOperations().iterator();
+ loopend:
+ while(iter.hasNext()){
+ BindingOperation bOp = (BindingOperation)iter.next();
+ if
(bOp.getName().equals(msg.getOperation().getName())){
+ for (Object ext :
bOp.getBindingInput().getExtensibilityElements()){
+ if (ext instanceof
javax.wsdl.extensions.soap.SOAPBody){
+ wrapperNamespace =
((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI();
+ break loopend;
+ }
+ }
+ }
+ }
+ }
+
+ if (wrapperNamespace == null){
+ wrapperNamespace =
wsBinding.getWSDLDefinition().getNamespace();
}
+
+ QName operationQName = new QName(wrapperNamespace,
+ msg.getOperation().getName());
+ OMElement operationNameElement =
factory.createOMElement(operationQName);
+
+ // add the parameters as children of the operation name element
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ operationNameElement.addChild((OMElement)bc);
+ } else {
+ throw new IllegalArgumentException( "Can't handle
mixed payloads between OMElements and other types for endpoint reference " +
endpointReference);
+ }
+ }
+
+ SOAPBody body = env.getBody();
+ body.addChild(operationNameElement);
+
+ } else if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not
supported for endpoint reference " + endpointReference);
+ } else if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not
supported for endpoint reference " + endpointReference);
+ // } else if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped
WSDL style not supported for endpoint reference " + endpointReference);
+ } else if (wsBinding.isDocLiteralWrapped() ||
+ wsBinding.isDocLiteralUnwrapped()){
+ // it's doc/lit
+ SOAPBody body = env.getBody();
+ for (Object bc : args) {
+ if (bc instanceof OMElement) {
+ body.addChild((OMElement)bc);
+ } else {
+ throw new IllegalArgumentException( "Can't handle
mixed payloads between OMElements and other types for endpoint reference " +
endpointReference);
+ }
+ }
+ } else {
+ throw new ServiceRuntimeException("Unrecognized WSDL style for
endpoint reference " + endpointReference);
}
}
+
final MessageContext requestMC = new MessageContext();
requestMC.setEnvelope(env);
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ReferenceBindingProvider.java
Wed Jun 30 10:06:46 2010
@@ -40,7 +40,9 @@ import javax.xml.transform.dom.DOMSource
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReferenceHelper;
@@ -122,6 +124,19 @@ public class Axis2ReferenceBindingProvid
for (PolicyProvider pp : this.endpointReference.getPolicyProviders()) {
pp.configureBinding(this);
}
+
+ // check the WSDL style as we currently only support some of them
+ if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not
supported for endpoint reference " + endpointReference);
+ }
+
+ if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not
supported for endpoint reference " + endpointReference);
+ }
+
+ if (wsBinding.isDocLiteralUnwrapped()){
+ //throw new ServiceRuntimeException("doc/literal/unwrapped WSDL
style not supported for endpoint reference " + endpointReference);
+ }
}
public void start() {
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/Axis2ServiceBindingProvider.java
Wed Jun 30 10:06:46 2010
@@ -166,6 +166,20 @@ public class Axis2ServiceBindingProvider
// TODO - do we need to go back to configurator?
}
wsBinding.setURI(deployedURI);
+
+ // Check the WSDL style as we only support some of them
+
+ if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not
supported for endpoint " + endpoint);
+ }
+
+ if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not
supported for endpoint " + endpoint);
+ }
+
+ // if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL
style not supported for endpoint " + endpoint);
+ // }
}
private static final String DEFAULT_QUEUE_CONNECTION_FACTORY =
"TuscanyQueueConnectionFactory";
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws-runtime-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/provider/TuscanyServiceProvider.java
Wed Jun 30 10:06:46 2010
@@ -20,11 +20,19 @@
package org.apache.tuscany.sca.binding.ws.axis2.provider;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.logging.Logger;
+import javax.wsdl.BindingOperation;
import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.soap.SOAPBody;
import org.apache.axiom.soap.SOAPHeader;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.AddressingConstants;
@@ -42,6 +50,7 @@ import org.apache.tuscany.sca.interfaced
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.oasisopen.sca.ServiceRuntimeException;
public class TuscanyServiceProvider {
private static final Logger logger =
Logger.getLogger(TuscanyServiceProvider.class.getName());
@@ -101,10 +110,35 @@ public class TuscanyServiceProvider {
// create a message object and set the args as its body
Message msg = messageFactory.createMessage();
- Object[] args = new Object[] {requestOM};
- msg.setBody(args);
msg.setOperation(operation);
msg.setBindingContext(inMC);
+
+ if (wsBinding.isRpcLiteral()){
+ // remove the wrapping element containing
+ // the operation name
+ Iterator iter = requestOM.getChildElements();
+ List<OMNode> list = new ArrayList<OMNode>();
+ while(iter.hasNext()){
+ OMNode node = (OMNode)iter.next();
+ list.add(node);
+ }
+
+ Object[] args = list.toArray();
+ msg.setBody(args);
+
+ } else if (wsBinding.isRpcEncoded()){
+ throw new ServiceRuntimeException("rpc/encoded WSDL style not
supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocEncoded()){
+ throw new ServiceRuntimeException("doc/encoded WSDL style not
supported for endpoint " + endpoint);
+ //} else if (wsBinding.isDocLiteralUnwrapped()){
+ // throw new ServiceRuntimeException("doc/literal/unwrapped WSDL
style not supported for endpoint " + endpoint);
+ } else if (wsBinding.isDocLiteralWrapped() ||
+ wsBinding.isDocLiteralUnwrapped()){
+ Object[] args = new Object[] {requestOM};
+ msg.setBody(args);
+ } else {
+ throw new ServiceRuntimeException("Unrecognized WSDL style for
endpoint " + endpoint);
+ }
//FIXME: can we use the Axis2 addressing support for this?
SOAPHeader header = inMC.getEnvelope().getHeader();
@@ -141,7 +175,45 @@ public class TuscanyServiceProvider {
if(response.isFault()) {
throw new InvocationTargetException((Throwable)
response.getBody());
}
- return response.getBody();
+
+ OMElement responseOM = response.getBody();
+
+ if (wsBinding.isRpcLiteral()){
+ // add the response wrapping element
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ String wrapperNamespace = null;
+
+ // the rpc style creates a wrapper with a namespace where the
namespace is
+ // defined on the wsdl binding operation. If no binding is
provided by the
+ // user then default to the namespace of the WSDL itself.
+ if (wsBinding.getBinding() != null){
+ Iterator iter =
wsBinding.getBinding().getBindingOperations().iterator();
+ loopend:
+ while(iter.hasNext()){
+ BindingOperation bOp = (BindingOperation)iter.next();
+ if (bOp.getName().equals(msg.getOperation().getName())){
+ for (Object ext :
bOp.getBindingOutput().getExtensibilityElements()){
+ if (ext instanceof
javax.wsdl.extensions.soap.SOAPBody){
+ wrapperNamespace =
((javax.wsdl.extensions.soap.SOAPBody)ext).getNamespaceURI();
+ break loopend;
+ }
+ }
+ }
+ }
+ }
+
+ if (wrapperNamespace == null){
+ wrapperNamespace =
wsBinding.getWSDLDefinition().getNamespace();
+ }
+
+ QName operationResponseQName = new QName(wrapperNamespace,
+ msg.getOperation().getName() +
"Response");
+ OMElement operationResponseElement =
factory.createOMElement(operationResponseQName);
+ operationResponseElement.addChild(responseOM);
+ responseOM = operationResponseElement;
+ }
+
+ return responseOM;
} // end method
private static String WS_REF_PARMS = "WS_REFERENCE_PARAMETERS";
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
Wed Jun 30 10:06:46 2010
@@ -31,6 +31,8 @@ import java.util.logging.Logger;
import javax.wsdl.Binding;
import javax.wsdl.Definition;
import javax.wsdl.Import;
+import javax.wsdl.Message;
+import javax.wsdl.Part;
import javax.wsdl.Port;
import javax.wsdl.PortType;
import javax.wsdl.Service;
@@ -260,6 +262,23 @@ public class WSDLServiceGenerator {
}
helper.createBindingOperations(def, binding, portType);
binding.setUndefined(false);
+
+ // set binding style based on the interface specified by the
+ // user if one is available
+ // TODO - set encoding style also currently default to literal
+ 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){
+ for (Object ext : binding.getExtensibilityElements()){
+ if (ext instanceof SOAPBinding){
+ ((SOAPBinding)ext).setStyle("rpc");
+ break;
+ }
+ }
+ }
+ }
+
def.addBinding(binding);
String endpointURI = computeActualURI(wsBinding, null);
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
Wed Jun 30 10:06:46 2010
@@ -214,5 +214,30 @@ public interface WebServiceBinding exten
* @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();
+}
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
URL:
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java?rev=959254&r1=959253&r2=959254&view=diff
==============================================================================
---
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
(original)
+++
tuscany/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
Wed Jun 30 10:06:46 2010
@@ -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 W
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 W
if (binding == null) {
if (getWSDLDefinition() != null && wsdlDefinition.getBinding() !=
null) {
binding = wsdlDefinition.getBinding();
+ setIsDocumentStyle();
+ setIsLiteralEncoding();
}
}
return binding;
@@ -191,6 +202,8 @@ class WebServiceBindingImpl implements W
public void setBinding(Binding binding) {
this.binding = binding;
+ setIsDocumentStyle();
+ setIsLiteralEncoding();
}
public void setBindingName(QName bindingName) {
@@ -293,6 +306,8 @@ class WebServiceBindingImpl implements W
public void setGeneratedWSDLDocument(Definition definition) {
this.generatedWSDLDocument = definition;
+ setIsDocumentStyle();
+ setIsLiteralEncoding();
}
public QName getType() {
@@ -318,5 +333,87 @@ class WebServiceBindingImpl implements W
}
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);
+ }
}