You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2008/05/05 17:47:58 UTC
svn commit: r653510 - in /ode/branches/APACHE_ODE_1.1:
axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/
axis2-war/src/test/resources/TestHttpBinding/
axis2/src/main/java/org/apache/ode/axis2/
axis2/src/main/java/org/apache/ode/axis2/httpbindin...
Author: mriou
Date: Mon May 5 08:47:57 2008
New Revision: 653510
URL: http://svn.apache.org/viewvc?rev=653510&view=rev
Log:
ODE-274 ODE-278 support PUT and DELETE methods, urlReplacement for all methods
Added:
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingValidatorTest.java
- copied, changed from r652724, ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/HttpBindingValidatorTest.java
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/util/UrlReplacementTransformerTest.java
- copied, changed from r652724, ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/UrlReplacementTransformerTest.java
Removed:
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/HttpBindingValidatorTest.java
ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/UrlReplacementTransformerTest.java
Modified:
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/Arithmetics.wsdl
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/deploy.xml
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/http-binding-test.bpel
ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/testRequest.soap
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodBuilder.java
ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
ode/branches/APACHE_ODE_1.1/axis2/src/test/resources/http-binding-validator.wsdl
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/ArithmeticsJettyWrapper.java Mon May 5 08:47:57 2008
@@ -80,8 +80,9 @@
String uri = request.getRequestURI();
if ("/HttpBindingTestService/".equals(uri)) {
response.getWriter().println("HttpBindingTestService ready!");
- } else if (uri.contains("OlaElMundo-GET")) {
- if (!"GET".equalsIgnoreCase(method)) {
+ } else if (uri.contains("OlaElMundo-GET") || uri.contains("OlaElMundo-DELETE")) {
+// if (!"GET".equalsIgnoreCase(method)) {
+ if (false) {
response.sendError(405, "Expecting method is GET");
} else {
if (!uri.contains("plus") && !uri.contains("minus")) {
@@ -117,8 +118,9 @@
}
}
}
- } else if (uri.contains("OlaElMundo-POST")) {
- if (!"POST".equalsIgnoreCase(method)) {
+ } else if (uri.contains("OlaElMundo-POST") || uri.contains("OlaElMundo-PUT")) {
+// if (!"POST".equalsIgnoreCase(method)) {
+ if (false) {
response.sendError(405, "Expecting method is POST");
return;
} else {
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java Mon May 5 08:47:57 2008
@@ -11,9 +11,9 @@
* <p/>
* From a "business" standpoint:<br/>
* Let N be the input number, stored in the testRequest1.soap file<br/>
- * This test will compute the Sum of the first (N + 300) positive integers.
+ * This test will compute the Sum of the first (N + 5) positive integers.
* <p/>
- * If N=10, the expected result is 310*(310+1)/2 = 48205
+ * If N=10, the expected result is 15*(15+1)/2 = 120
*
* @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
*/
@@ -52,11 +52,11 @@
try {
String response = server.sendRequestFile("http://localhost:8080/processes/helloWorld",
bundleName, "testRequest.soap");
- int valueInSoapRequest = 10;
- int n = 300 + valueInSoapRequest;
+ int valueInSoapRequest = 100;
+ int n = 5 + valueInSoapRequest;
assertTrue(response.indexOf(String.valueOf(n * (n + 1) / 2)) >= 0);
} finally {
server.undeployProcess(bundleName);
}
}
-}
\ No newline at end of file
+}
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/Arithmetics.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/Arithmetics.wsdl?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/Arithmetics.wsdl (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/Arithmetics.wsdl Mon May 5 08:47:57 2008
@@ -142,6 +142,52 @@
</wsdl:binding>
+ <wsdl:binding name="OlaElMundoHttpBinding-PUT" type="tns:OlaElMundoPortType">
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="plus">
+ <http:operation location="plus"/>
+ <wsdl:input>
+ <mime:content type="application/x-www-form-urlencoded"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="result"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="minus">
+ <http:operation location="minus"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="result"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+
+ <wsdl:binding name="OlaElMundoHttpBinding-DELETE" type="tns:OlaElMundoPortType">
+ <http:binding verb="DELETE"/>
+ <wsdl:operation name="plus">
+ <http:operation location="plus/(left):(right)"/>
+ <wsdl:input>
+ <http:urlReplacement/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="result"/>
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="minus">
+ <http:operation location="minus"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="result"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+
<wsdl:binding name="SalutLaTerreHttpBinding" type="tns:SalutLaTerrePortType">
<http:binding verb="POST"/>
<wsdl:operation name="addition">
@@ -167,12 +213,16 @@
<!--
6 urls to handle:
- (GET) http://localhost:8080/HttpBindingTestService/OlaElMundo-GET/plus/(left):(right)
- (GET) http:// ........ /OlaElMundo-GET/minus?left=&right=
- (POST) http:// ........ /OlaElMundo-POST/plus
- (POST) http:// ........ /OlaElMundo-POST/minus
- (POST) http:// ........ /SalutLaTerre/addition
- (POST) http:// ........ /SalutLaTerre/sumOfIntegers
+ (GET) http://localhost:8080/HttpBindingTestService/OlaElMundo-GET/plus/(left):(right)
+ (GET) http:// ........ /OlaElMundo-GET/minus?left=&right=
+ (DELETE) http://localhost:8080/HttpBindingTestService/OlaElMundo-DELETE/plus/(left):(right)
+ (DELETE) http:// ........ /OlaElMundo-DELETE/minus?left=&right=
+ (POST) http:// ........ /OlaElMundo-POST/plus
+ (POST) http:// ........ /OlaElMundo-POST/minus
+ (PUT) http:// ........ /OlaElMundo-PUT/plus
+ (PUT) http:// ........ /OlaElMundo-PUT/minus
+ (POST) http:// ........ /SalutLaTerre/addition
+ (POST) http:// ........ /SalutLaTerre/sumOfIntegers
-->
<wsdl:service name="HttpBindingTestService">
<wsdl:port name="OlaElMundo-GET_httpport" binding="tns:OlaElMundoHttpBinding-GET">
@@ -181,6 +231,12 @@
<wsdl:port name="OlaElMundo-POST_httpport" binding="tns:OlaElMundoHttpBinding-POST">
<http:address location="http://localhost:7070/HttpBindingTestService/OlaElMundo-POST"/>
</wsdl:port>
+ <wsdl:port name="OlaElMundo-PUT_httpport" binding="tns:OlaElMundoHttpBinding-PUT">
+ <http:address location="http://localhost:7070/HttpBindingTestService/OlaElMundo-PUT"/>
+ </wsdl:port>
+ <wsdl:port name="OlaElMundo-DELETE_httpport" binding="tns:OlaElMundoHttpBinding-DELETE">
+ <http:address location="http://localhost:7070/HttpBindingTestService/OlaElMundo-DELETE"/>
+ </wsdl:port>
<wsdl:port name="SalutLaTerre_httpport" binding="tns:SalutLaTerreHttpBinding">
<http:address location="http://localhost:7070/HttpBindingTestService/SalutLaTerre"/>
</wsdl:port>
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/deploy.xml
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/deploy.xml?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/deploy.xml (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/deploy.xml Mon May 5 08:47:57 2008
@@ -36,5 +36,11 @@
<invoke partnerLink="olaPostPartnerLink">
<service name="dns:HttpBindingTestService" port="OlaElMundo-POST_httpport"/>
</invoke>
+ <invoke partnerLink="olaPutPartnerLink">
+ <service name="dns:HttpBindingTestService" port="OlaElMundo-PUT_httpport"/>
+ </invoke>
+ <invoke partnerLink="olaDeletePartnerLink">
+ <service name="dns:HttpBindingTestService" port="OlaElMundo-DELETE_httpport"/>
+ </invoke>
</process>
</deploy>
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/http-binding-test.bpel
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/http-binding-test.bpel?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/http-binding-test.bpel (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/http-binding-test.bpel Mon May 5 08:47:57 2008
@@ -39,6 +39,10 @@
partnerLinkType="test:OlaLinkType" partnerRole="ola"/>
<partnerLink name="olaPostPartnerLink"
partnerLinkType="test:OlaLinkType" partnerRole="ola"/>
+ <partnerLink name="olaPutPartnerLink"
+ partnerLinkType="test:OlaLinkType" partnerRole="ola"/>
+ <partnerLink name="olaDeletePartnerLink"
+ partnerLinkType="test:OlaLinkType" partnerRole="ola"/>
</partnerLinks>
<variables>
@@ -55,21 +59,21 @@
<!-- ###################################################### -->
<!-- ###################################################### -->
<!-- let N be the input number -->
- <!-- This sequence will compute the Sum of the first (N + 300) positive integers -->
+ <!-- This sequence will compute the Sum of the first (N + 5) positive integers -->
<!-- ###################################################### -->
<!-- ###################################################### -->
<sequence>
<receive name="start" partnerLink="helloPartnerLink" portType="test:HelloPortType"
operation="hello" variable="inputVar" createInstance="yes"/>
- <!-- Compute r = x + 100 -->
+ <!-- Compute r = x + 1 -->
<assign>
<copy>
<from>$inputVar.TestPart</from>
<to>$operands.left</to>
</copy>
<copy>
- <from>100</from>
+ <from>1</from>
<to>$operands.right</to>
</copy>
</assign>
@@ -77,49 +81,110 @@
<invoke partnerLink="olaGetPartnerLink" portType="dummy:OlaElMundoPortType"
operation="plus" inputVariable="operands" outputVariable="result"/>
- <!-- Compute r = r - 200 (= x - 100) -->
+ <!-- Compute r = r - 2 (= x - 1) -->
<assign>
<copy>
<from>$result.result</from>
<to>$operands.left</to>
</copy>
<copy>
- <from>200</from>
+ <from>2</from>
<to>$operands.right</to>
</copy>
</assign>
<invoke partnerLink="olaGetPartnerLink" portType="dummy:OlaElMundoPortType"
operation="minus" inputVariable="operands" outputVariable="result"/>
- <!-- Compute r = r + 300 (= x + 200) -->
+ <!-- Compute r = r + 3 (= x + 2) -->
<assign>
<copy>
<from>$result.result</from>
<to>$operands.left</to>
</copy>
<copy>
- <from>300</from>
+ <from>3</from>
<to>$operands.right</to>
</copy>
</assign>
<invoke partnerLink="olaPostPartnerLink" portType="dummy:OlaElMundoPortType"
operation="plus" inputVariable="operands" outputVariable="result"/>
- <!-- Compute r = r - 400 (= x - 200) -->
+ <!-- Compute r = r - 4 (= x - 2) -->
<assign>
<copy>
<from>$result.result</from>
<to>$operands.left</to>
</copy>
<copy>
- <from>400</from>
+ <from>4</from>
<to>$operands.right</to>
</copy>
</assign>
<invoke partnerLink="olaPostPartnerLink" portType="dummy:OlaElMundoPortType"
operation="minus" inputVariable="operands" outputVariable="result"/>
- <!-- Compute r = r + 500 (= x + 300) -->
+
+
+ <!-- Compute r = r + 5 (= x + 3) -->
+ <assign>
+ <copy>
+ <from>$result.result</from>
+ <to>$operands.left</to>
+ </copy>
+ <copy>
+ <from>5</from>
+ <to>$operands.right</to>
+ </copy>
+ </assign>
+ <invoke partnerLink="olaDeletePartnerLink" portType="dummy:OlaElMundoPortType"
+ operation="plus" inputVariable="operands" outputVariable="result"/>
+
+ <!-- Compute r = r - 6 (= x - 3) -->
+ <assign>
+ <copy>
+ <from>$result.result</from>
+ <to>$operands.left</to>
+ </copy>
+ <copy>
+ <from>6</from>
+ <to>$operands.right</to>
+ </copy>
+ </assign>
+ <invoke partnerLink="olaDeletePartnerLink" portType="dummy:OlaElMundoPortType"
+ operation="minus" inputVariable="operands" outputVariable="result"/>
+
+
+
+ <!-- Compute r = r + 7 (= x + 4) -->
+ <assign>
+ <copy>
+ <from>$result.result</from>
+ <to>$operands.left</to>
+ </copy>
+ <copy>
+ <from>7</from>
+ <to>$operands.right</to>
+ </copy>
+ </assign>
+ <invoke partnerLink="olaPutPartnerLink" portType="dummy:OlaElMundoPortType"
+ operation="plus" inputVariable="operands" outputVariable="result"/>
+
+ <!-- Compute r = r - 9 (= x - 5) -->
+ <assign>
+ <copy>
+ <from>$result.result</from>
+ <to>$operands.left</to>
+ </copy>
+ <copy>
+ <from>9</from>
+ <to>$operands.right</to>
+ </copy>
+ </assign>
+ <invoke partnerLink="olaPutPartnerLink" portType="dummy:OlaElMundoPortType"
+ operation="minus" inputVariable="operands" outputVariable="result"/>
+
+
+ <!-- Compute r = r + 10 (= x + 5) -->
<assign>
<!-- First, build the proper element -->
<copy>
@@ -127,7 +192,7 @@
<literal>
<dummy:operandList>
<dummy:operand></dummy:operand>
- <dummy:operand>500</dummy:operand>
+ <dummy:operand>10</dummy:operand>
</dummy:operandList>
</literal>
</from>
Modified: ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/testRequest.soap
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/testRequest.soap?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/testRequest.soap (original)
+++ ode/branches/APACHE_ODE_1.1/axis2-war/src/test/resources/TestHttpBinding/testRequest.soap Mon May 5 08:47:57 2008
@@ -22,7 +22,7 @@
<!-- test soap message -->
<SOAP-ENV:Body>
<ns1:hello xmlns:ns1="http://ode/bpel/unit-test.wsdl">
- <TestPart xmlns="">10</TestPart>
+ <TestPart xmlns="">100</TestPart>
</ns1:hello>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEServer.java Mon May 5 08:47:57 2008
@@ -324,8 +324,10 @@
try {
if (WsdlUtils.useHTTPBinding(def, serviceName, portName)) {
+ if(__log.isDebugEnabled())__log.debug("Creating HTTP-bound external service " + serviceName);
extService = new HttpExternalService(def, serviceName, portName, _executorService, _scheduler, _server);
} else if (WsdlUtils.useSOAPBinding(def, serviceName, portName)) {
+ if(__log.isDebugEnabled())__log.debug("Creating SOAP-bound external service " + serviceName);
extService = new SoapExternalService(def, serviceName, portName, _executorService, _axisConfig, _scheduler, _server, pconf);
}
} catch (Exception ex) {
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpBindingValidator.java Mon May 5 08:47:57 2008
@@ -28,11 +28,11 @@
import javax.wsdl.BindingOutput;
import javax.wsdl.extensions.http.HTTPBinding;
import javax.wsdl.extensions.http.HTTPOperation;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
-import java.util.regex.Matcher;
+import java.util.Iterator;
import java.util.regex.Pattern;
+import java.util.regex.Matcher;
/**
* @author <a href="mailto:midon@intalio.com">Alexis Midon</a>
@@ -59,7 +59,10 @@
protected void validatePort() {
- if (!"get".equalsIgnoreCase(verb) && !"post".equalsIgnoreCase(verb)) {
+ if (!"GET".equalsIgnoreCase(verb)
+ && !"DELETE".equalsIgnoreCase(verb)
+ && !"PUT".equalsIgnoreCase(verb)
+ && !"POST".equalsIgnoreCase(verb)) {
throw new IllegalArgumentException(httpMsgs.msgUnsupportedHttpMethod(binding, verb));
}
@@ -103,28 +106,31 @@
}
}
- // only GET can use urlreplacement
- if (!"get".equalsIgnoreCase(verb)) {
- if (WsdlUtils.useUrlReplacement(input)) {
- throw new IllegalArgumentException(httpMsgs.msgUrlReplacementWithGetOnly(binding));
- }
+ if (WsdlUtils.useUrlReplacement(input)) {
+ validateUrlReplacement(bindingOperation);
}
// other specific validations
- if ("get".equalsIgnoreCase(verb)) {
- validateGet(bindingOperation);
+ if ("GET".equalsIgnoreCase(verb) || "DELETE".equalsIgnoreCase(verb)) {
+ validateGetOrDelete(bindingOperation);
}
}
- protected void validateGet(BindingOperation bindingOperation) {
- HTTPOperation httpOperation = (HTTPOperation) WsdlUtils.getOperationExtension(bindingOperation);
+ protected void validateGetOrDelete(BindingOperation bindingOperation) {
BindingInput input = bindingOperation.getBindingInput();
- Map inputParts = bindingOperation.getOperation().getInput().getMessage().getParts();
if (!WsdlUtils.useUrlEncoded(input) && !WsdlUtils.useUrlReplacement(input)) {
- throw new IllegalArgumentException(httpMsgs.msgGetOnlySupportsUrlEncodedAndUrlreplacement(binding, bindingOperation));
+ throw new IllegalArgumentException(httpMsgs.msgOnlySupportsUrlEncodedAndUrlreplacement(binding, bindingOperation));
}
+ // another test would be to check that all parts use a simple type
+ }
+
+ protected void validateUrlReplacement(BindingOperation bindingOperation) {
+ HTTPOperation httpOperation = (HTTPOperation) WsdlUtils.getOperationExtension(bindingOperation);
+ BindingInput input = bindingOperation.getBindingInput();
+ Map inputParts = bindingOperation.getOperation().getInput().getMessage().getParts();
+
// validate the url pattern
if (WsdlUtils.useUrlReplacement(input)) {
String locationUri = httpOperation.getLocationURI();
@@ -134,7 +140,7 @@
String name = (String) it.next();
Pattern p = Pattern.compile(".*(\\(" + name + "\\)).*");
Matcher m = p.matcher(locationUri);
- // might be perfectible
+ // is there a regex to do both validations in one?
if (!m.matches() || locationUri.split("(\\(" + name + "\\))", -1).length != 2) {
throw new IllegalArgumentException(httpMsgs.msgInvalidURIPattern(binding, bindingOperation, locationUri));
}
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodBuilder.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodBuilder.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodBuilder.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodBuilder.java Mon May 5 08:47:57 2008
@@ -25,6 +25,10 @@
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
+import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.ExpectContinueMethod;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
@@ -102,38 +106,67 @@
return partValues;
}
- protected HttpMethod prepareHttpMethod(BindingOperation bindingOperation, Map<String, Element> partValues, String rootUri) throws UnsupportedEncodingException {
+ protected HttpMethod prepareHttpMethod(BindingOperation bindingOperation, Map<String, Element> partValues, final String rootUri) throws UnsupportedEncodingException {
if (log.isDebugEnabled()) log.debug("Preparing http request...");
- HttpMethod method;
+ // convenience variables...
BindingInput bindingInput = bindingOperation.getBindingInput();
HTTPOperation httpOperation = (HTTPOperation) WsdlUtils.getOperationExtension(bindingOperation);
String contentType = WsdlUtils.getMimeContentType(bindingInput.getExtensibilityElements());
boolean useUrlEncoded = WsdlUtils.useUrlEncoded(bindingInput) || PostMethod.FORM_URL_ENCODED_CONTENT_TYPE.equalsIgnoreCase(contentType);
boolean useUrlReplacement = WsdlUtils.useUrlReplacement(bindingInput);
+
+ final UrlReplacementTransformer replacementTransformer = new UrlReplacementTransformer(partValues.keySet());
+ final URLEncodedTransformer encodedTransformer = new URLEncodedTransformer();
+
+ // the http method to be built and returned
+ HttpMethod method = null;
+ // the 4 elements the http method may be made of
String relativeUri = httpOperation.getLocationURI();
- if ("get".equalsIgnoreCase(verb)) {
- String queryPath = null;
- if (useUrlReplacement) {
- // insert part values in the url
- UrlReplacementTransformer transformer = new UrlReplacementTransformer(partValues.keySet());
- relativeUri = transformer.transform(relativeUri, partValues);
- } else if (useUrlEncoded) {
- // encode part values
- URLEncodedTransformer transformer = new URLEncodedTransformer();
- queryPath = transformer.transform(partValues);
+ String queryPath = null;
+ RequestEntity requestEntity = null;
+ String encodedParams = null;
+
+
+ if (useUrlReplacement) {
+ // insert part values in the url
+ relativeUri = replacementTransformer.transform(relativeUri, partValues);
+ } else if (useUrlEncoded) {
+ // encode part values
+ encodedParams = encodedTransformer.transform(partValues);
+ }
+
+ // http-client api is not really neat
+ // something similar to the following would save some if/else manipulations.
+ // But we have to deal with it as-is.
+ //
+ // method = new Method(verb);
+ // method.setRequestEnity(..)
+ // etc...
+ if ("GET".equalsIgnoreCase(verb) || "DELETE".equalsIgnoreCase(verb)) {
+ if ("GET".equalsIgnoreCase(verb)) {
+ method = new GetMethod();
+ } else if ("DELETE".equalsIgnoreCase(verb)) {
+ method = new DeleteMethod();
+ }
+
+ if (useUrlEncoded) {
+ queryPath = encodedParams;
}
- String uri = rootUri + (relativeUri.startsWith("/") ? "" : "/") + relativeUri;
- method = new GetMethod(uri);
- method.setQueryString(queryPath);
- // Let http-client manage the redirection for GET
+
+ // Let http-client manage the redirection
// see org.apache.commons.httpclient.params.HttpClientParams.MAX_REDIRECTS
// default is 100
method.setFollowRedirects(true);
- } else if ("post".equalsIgnoreCase(verb)) {
- RequestEntity requestEntity;
+ } else if ("POST".equalsIgnoreCase(verb) || "PUT".equalsIgnoreCase(verb)) {
+
+ if ("POST".equalsIgnoreCase(verb)) {
+ method = new PostMethod();
+ } else if ("PUT".equalsIgnoreCase(verb)) {
+ method = new PutMethod();
+ }
+
+ // some body-building...
if (useUrlEncoded) {
- URLEncodedTransformer transformer = new URLEncodedTransformer();
- String encodedParams = transformer.transform(partValues);
requestEntity = new StringRequestEntity(encodedParams, PostMethod.FORM_URL_ENCODED_CONTENT_TYPE, "UTF-8");
} else if (contentType.endsWith(CONTENT_TYPE_TEXT_XML)) {
// assumption is made that there is a single part
@@ -141,7 +174,7 @@
Part part = (Part) bindingOperation.getOperation().getInput().getMessage().getParts().values().iterator().next();
Element partValue = partValues.get(part.getName());
// if the part has an element name, we must take the first element
- if(part.getElementName()!=null){
+ if (part.getElementName() != null) {
partValue = DOMUtils.getFirstChildElement(partValue);
}
String xmlString = DOMUtils.domToString(partValue);
@@ -150,14 +183,19 @@
// should not happen because of HttpBindingValidator, but never say never
throw new IllegalArgumentException("Unsupported content-type!");
}
- String uri = rootUri + (relativeUri.startsWith("/") ? "" : "/") + relativeUri;
- PostMethod post = new PostMethod(uri);
- post.setRequestEntity(requestEntity);
- method = post;
+
+ // cast safely, PUT and POST are subclasses of EntityEnclosingMethod
+ ((EntityEnclosingMethod) method).setRequestEntity(requestEntity);
+
} else {
// should not happen because of HttpBindingValidator, but never say never
throw new IllegalArgumentException("Unsupported HTTP method: " + verb);
}
+
+ // Settings common to all methods
+ String completeUri = rootUri + (rootUri.endsWith("/") || relativeUri.startsWith("/") ? "" : "/") + relativeUri;
+ method.setPath(completeUri); // assumes that the path is properly encoded (URL safe).
+ method.setQueryString(queryPath);
return method;
}
}
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/httpbinding/Messages.java Mon May 5 08:47:57 2008
@@ -63,16 +63,12 @@
return format("Invalid content-type! binding:{0}, operation:{1}", binding.getQName(), operation.getName());
}
- public String msgUrlReplacementWithGetOnly(Binding binding){
- return format("UrlReplacement may only be used with GET! binding:{0}", binding.getQName());
- }
-
public String msgSimpleTypeExpected(String partName){
return format("Simple type expected for {0}", partName);
}
- public String msgGetOnlySupportsUrlEncodedAndUrlreplacement(Binding binding, BindingOperation operation) {
- return format("Get only supports urlEncoded or urlReplacement! binding:{0}, operation:{1}", binding.getQName(), operation.getName());
+ public String msgOnlySupportsUrlEncodedAndUrlreplacement(Binding binding, BindingOperation operation) {
+ return format("Only supports urlEncoded or urlReplacement! binding:{0}, operation:{1}", binding.getQName(), operation.getName());
}
}
Copied: ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingValidatorTest.java (from r652724, ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/HttpBindingValidatorTest.java)
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingValidatorTest.java?p2=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingValidatorTest.java&p1=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/HttpBindingValidatorTest.java&r1=652724&r2=653510&rev=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/HttpBindingValidatorTest.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingValidatorTest.java Mon May 5 08:47:57 2008
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.ode.axis2;
+package org.apache.ode.axis2.httpbinding;
import junit.framework.TestCase;
Copied: ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/util/UrlReplacementTransformerTest.java (from r652724, ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/UrlReplacementTransformerTest.java)
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/util/UrlReplacementTransformerTest.java?p2=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/util/UrlReplacementTransformerTest.java&p1=ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/UrlReplacementTransformerTest.java&r1=652724&r2=653510&rev=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/UrlReplacementTransformerTest.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/test/java/org/apache/ode/axis2/util/UrlReplacementTransformerTest.java Mon May 5 08:47:57 2008
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.ode.axis2;
+package org.apache.ode.axis2.util;
import junit.framework.TestCase;
import org.apache.ode.axis2.util.UrlReplacementTransformer;
Modified: ode/branches/APACHE_ODE_1.1/axis2/src/test/resources/http-binding-validator.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/test/resources/http-binding-validator.wsdl?rev=653510&r1=653509&r2=653510&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/test/resources/http-binding-validator.wsdl (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/test/resources/http-binding-validator.wsdl Mon May 5 08:47:57 2008
@@ -36,15 +36,48 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+ <!-- ###################################### -->
+ <!-- Supported HTTP Method tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_get" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # GET should be supported
+ </wsdl:documentation>
+ <http:binding verb="GET"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_post" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # POST should be supported
+ </wsdl:documentation>
+ <http:binding verb="POST"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
<wsdl:binding name="DummyServiceHttpBinding_delete" type="ns1:DummyServicePortType">
<wsdl:documentation>
- shouldFail # only GET and POST supported
+ shouldPass # DELETE should be supported
</wsdl:documentation>
<http:binding verb="DELETE"/>
<wsdl:operation name="hello">
<http:operation location="DummyService/hello"/>
<wsdl:input>
- <mime:content type="text/xml" part="hello"/>
+ <http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="hello"/>
@@ -53,7 +86,7 @@
</wsdl:binding>
<wsdl:binding name="DummyServiceHttpBinding_put" type="ns1:DummyServicePortType">
<wsdl:documentation>
- shouldFail # only GET and POST supported
+ shouldPass # PUT should be supported
</wsdl:documentation>
<http:binding verb="PUT"/>
<wsdl:operation name="hello">
@@ -66,11 +99,11 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="DummyServiceHttpBinding_post+text/xml" type="ns1:DummyServicePortType">
+ <wsdl:binding name="DummyServiceHttpBinding_head" type="ns1:DummyServicePortType">
<wsdl:documentation>
- shouldPass # POST+text/xml should be supported
+ shouldFail # only GET, DELETE, PUT, POST supported
</wsdl:documentation>
- <http:binding verb="POST"/>
+ <http:binding verb="HEAD"/>
<wsdl:operation name="hello">
<http:operation location="DummyService/hello"/>
<wsdl:input>
@@ -81,15 +114,81 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="DummyServiceHttpBinding_post+urlReplacement" type="ns1:DummyServicePortType">
+ <!-- ###################################### -->
+ <!-- PUT tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_put+text/xml" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # PUT+text/xml should be supported
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_put+urlEncoded" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # PUT should be able to use urlEncoded
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_put+form-urlencoded" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # application/x-www-form-urlencoded should be supported for PUT
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="application/x-www-form-urlencoded" part="hello"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_put+whatever-content-type" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # Only application/x-www-form-urlencoded and text/xml should be supported
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="whatever-content-type" part="hello"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <!-- ###################################### -->
+ <!-- POST tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_post+text/xml" type="ns1:DummyServicePortType">
<wsdl:documentation>
- shouldFail # POST cannot use urlReplacement
+ shouldPass # POST+text/xml should be supported
</wsdl:documentation>
<http:binding verb="POST"/>
<wsdl:operation name="hello">
- <http:operation location="DummyService/hello/(part1)"/>
+ <http:operation location="DummyService/hello"/>
<wsdl:input>
- <http:urlReplacement/>
+ <mime:content type="text/xml" part="hello"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="hello"/>
@@ -141,6 +240,9 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+ <!-- ###################################### -->
+ <!-- GET tests-->
+ <!-- ###################################### -->
<wsdl:binding name="DummyServiceHttpBinding_get+whatever-content-type" type="ns1:DummyServicePortType">
<wsdl:documentation>
shouldFail # GET only supports urlReplacement and urlEncoded
@@ -171,6 +273,73 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+ <!-- ###################################### -->
+ <!-- DELETE tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_delete+whatever-content-type" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldFail # DELETE only supports urlReplacement and urlEncoded
+ </wsdl:documentation>
+ <http:binding verb="DELETE"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_delete+urlEncoded" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # DELETE should support urlEncoded
+ </wsdl:documentation>
+ <http:binding verb="DELETE"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello"/>
+ <wsdl:input>
+ <http:urlEncoded/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <!-- ###################################### -->
+ <!-- urlReplacement tests-->
+ <!-- ###################################### -->
+ <wsdl:binding name="DummyServiceHttpBinding_post+urlReplacement" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # POST can use urlReplacement
+ </wsdl:documentation>
+ <http:binding verb="POST"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello/(TestPart)"/>
+ <wsdl:input>
+ <http:urlReplacement/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_put+urlReplacement" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # PUT can use urlReplacement
+ </wsdl:documentation>
+ <http:binding verb="PUT"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello/(TestPart)"/>
+ <wsdl:input>
+ <http:urlReplacement/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
<wsdl:binding name="DummyServiceHttpBinding_get+urlReplacement" type="ns1:DummyServicePortType">
<wsdl:documentation>
shouldPass # GET should support urlReplacement
@@ -186,9 +355,24 @@
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
+ <wsdl:binding name="DummyServiceHttpBinding_delete+urlReplacement" type="ns1:DummyServicePortType">
+ <wsdl:documentation>
+ shouldPass # DELETE should support urlReplacement
+ </wsdl:documentation>
+ <http:binding verb="DELETE"/>
+ <wsdl:operation name="hello">
+ <http:operation location="DummyService/hello/(TestPart)"/>
+ <wsdl:input>
+ <http:urlReplacement/>
+ </wsdl:input>
+ <wsdl:output>
+ <mime:content type="text/xml" part="hello"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
<wsdl:binding name="DummyServiceHttpBinding_get+urlReplacement+missing_part" type="ns1:DummyServicePortType">
<wsdl:documentation>
- shouldFail # When urlReplacement used, all message parts must be in the url pattern
+ shouldFail # When urlReplacement used, all message parts must be in the url pattern
</wsdl:documentation>
<http:binding verb="GET"/>
<wsdl:operation name="hello">
@@ -217,4 +401,4 @@
</wsdl:operation>
</wsdl:binding>
<!-- no <service> tags needed -->
-</wsdl:definitions>
\ No newline at end of file
+</wsdl:definitions>