Author: jkaputin
Date: Tue Jun 6 04:12:48 2006
New Revision: 412081
URL: http://svn.apache.org/viewvc?rev=412081&view=rev
Log:
Modified default behaviour reflect the current Part 2
spec and update comments to capture future changes
pending modification to the spec.
Modified:
incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/http/HTTPBindingOperationExtensionsImpl.java
Modified:
incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/http/HTTPBindingOperationExtensionsImpl.java
URL:
http://svn.apache.org/viewvc/incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/http/HTTPBindingOperationExtensionsImpl.java?rev=412081&r1=412080&r2=412081&view=diff
==============================================================================
---
incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/http/HTTPBindingOperationExtensionsImpl.java
(original)
+++
incubator/woden/java/src/org/apache/woden/internal/wsdl20/extensions/http/HTTPBindingOperationExtensionsImpl.java
Tue Jun 6 04:12:48 2006
@@ -18,8 +18,11 @@
import java.net.URI;
import org.apache.woden.internal.wsdl20.extensions.ComponentExtensionsImpl;
+import org.apache.woden.internal.wsdl20.extensions.ExtensionConstants;
import org.apache.woden.wsdl20.Binding;
import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.InterfaceOperation;
+import org.apache.woden.wsdl20.extensions.InterfaceOperationExtensions;
import org.apache.woden.wsdl20.extensions.http.HTTPBindingExtensions;
import org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions;
import org.apache.woden.wsdl20.xml.WSDLElement;
@@ -135,6 +138,11 @@
* (non-Javadoc)
*
* @see
org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions#getHttpInputSerialization()
+ *
+ * Per Part 2, sect 6.3.3, if this attribute is omitted then
+ * {http input serialization} will be application/x-www-form-urlencoded if
+ * {http method} is GET or DELETE, or application/xml if {http method} has
+ * any other value.
*/
public String getHttpInputSerialization() {
@@ -144,18 +152,15 @@
return serialization.getString();
}
- String method = getHttpMethod();
-
- //TODO Remove following null return if the Part 2 spec is improved
- //so that BindingOperation {http method} does not just default
- //to null (see ws-desc posting 30May06)
- if(method == null) return null;
+ //TODO replace determineHttpMethod() with getHttpMethod() if spec is
+ //modified to define {http method} defaults in the component model
+ String method = determineHttpMethod();
if (method.equals(HTTPConstants.METHOD_GET)
|| method.equals(HTTPConstants.METHOD_DELETE)) {
return HTTPConstants.SERIAL_APP_URLENCODED;
} else {
- // method is not GET or DELETE so it must be POST or
PUT.
+ // for POST, PUT or any other method type (Part 2 sect
6.3.3)
return HTTPConstants.SERIAL_APP_XML;
}
}
@@ -164,6 +169,10 @@
* (non-Javadoc)
*
* @see
org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions#getHttpOutputSerialization()
+ *
+ * Per Part 2, sect 6.3.3, if this attribute is omitted then
+ * {http output serialization} will be application/xml for any {http
method}
+ * value.
*/
public String getHttpOutputSerialization() {
StringAttr serialization = (StringAttr) ((WSDLElement) fParent)
@@ -176,6 +185,8 @@
* (non-Javadoc)
*
* @see
org.apache.woden.wsdl20.extensions.http.HTTPBindingOperationExtensions#getHttpFaultSerialization()
+ *
+ * Per Part 2, sect 6.4.5, if attribute omitted default to application/xml.
*/
public String getHttpFaultSerialization() {
StringAttr serialization = (StringAttr) ((WSDLElement) fParent)
@@ -220,5 +231,46 @@
.getExtensionAttribute(HTTPConstants.Q_ATTR_TRANSFER_CODING_DEFAULT);
return tfrCodingDef != null ? tfrCodingDef.getString() : null;
}
+
+ /*
+ * This default behaviour for http method is referred to in the spec
+ * Part 2 when determining default values for input and output
+ * serialization in the component model extensions (i.e. 6.3.3 refers
+ * to 6.3.1). If spec is changed to define this default behaviour directly
+ * for the {http method} property, this behaviour will move to the
+ * getHttpMethod() method and this private method can be removed.
+ */
+ private String determineHttpMethod() {
+
+ // 1. try whttp:method
+ String method = getHttpMethod();
+ if(method != null) return method;
+
+ // 2. try whttp:methodDefault
+ Binding binding = (Binding) ((BindingOperation) fParent).getParent();
+
+ HTTPBindingExtensions httpBindExts = (HTTPBindingExtensions) binding
+ .getComponentExtensionsForNamespace(HTTPConstants.NS_URI_HTTP);
+
+ // no need to check for a null httpBindExts because Binding has
REQUIRED
+ // http extension properties
+ String methodDef = httpBindExts.getHttpMethodDefault();
+ if (methodDef != null) return methodDef;
+
+ // 3. try {safety} equals True
+ InterfaceOperation intOper = ((BindingOperation) fParent)
+ .getInterfaceOperation();
+ if (intOper != null) {
+ InterfaceOperationExtensions intOperExts =
(InterfaceOperationExtensions) intOper
+ .getComponentExtensionsForNamespace(URI
+ .create(ExtensionConstants.NS_URI_WSDL_EXTENSIONS));
+ if (intOperExts != null && intOperExts.isSafety()) {
+ return HTTPConstants.METHOD_GET;
+ }
+ }
+
+ // 4. default to POST.
+ return HTTPConstants.METHOD_POST;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]