ODE-602: Message parts URLEncoded into the request body for post & put operations
Project: http://git-wip-us.apache.org/repos/asf/ode/repo Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/ff155256 Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/ff155256 Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/ff155256 Branch: refs/heads/ode-1.3.x Commit: ff15525632ab7b91e288012151a218474945a4e5 Parents: 73997d9 Author: sathwik <[email protected]> Authored: Fri Aug 4 13:20:25 2017 +0530 Committer: sathwik <[email protected]> Committed: Fri Aug 4 13:20:25 2017 +0530 ---------------------------------------------------------------------- .../ode/axis2/httpbinding/HttpBindingTest.java | 6 + .../Blog.wsdl | 169 +++++++++++++++++++ .../deploy.xml | 34 ++++ .../http-binding-ext-POST.bpel | 110 ++++++++++++ .../http-binding-ext-POST.wsdl | 73 ++++++++ .../testRequest.soap | 28 +++ .../axis2/httpbinding/HttpMethodConverter.java | 5 +- 7 files changed, 423 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java b/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java index cfe902b..b71bae1 100644 --- a/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java +++ b/axis2-war/src/test/java/org/apache/ode/axis2/httpbinding/HttpBindingTest.java @@ -101,6 +101,12 @@ public class HttpBindingTest extends Axis2TestBase { } @Test(dataProvider="configs") + public void testHttpBindingExt_POST_FORM_URL_ENCODED() throws Exception { + String bundleName = "TestHttpBindingExt_POST_FORM_URL_ENCODED"; + executeBundle(bundleName); + } + + @Test(dataProvider="configs") public void testHttpBindingExt_PUT() throws Exception { String bundleName = "TestHttpBindingExt_PUT"; executeBundle(bundleName); http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/Blog.wsdl ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/Blog.wsdl b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/Blog.wsdl new file mode 100644 index 0000000..03ab927 --- /dev/null +++ b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/Blog.wsdl @@ -0,0 +1,169 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<wsdl:definitions + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" + xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" + xmlns:tns="http://ode/bpel/test/blog" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:odex="http://www.apache.org/ode/type/extension/http" + targetNamespace="http://ode/bpel/test/blog"> + + + <!-- ## USE CASE ## --> + <!-- + Describe a REST service to access a blog article. + The article is a resource available at http://ex.org/blog/article/42 (for instance) + + For demonstration purpose, some requests/responses will have a custom header: TimestampHeader. + This header will be mapped to a part of the message. + + Also for demonstration, the User-agent header will be set in some requests. + --> + <wsdl:types> + <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ode/bpel/test/blog"> + <xsd:element name="article" type="tns:ArticleType"/> + <xsd:element name="comment" type="tns:CommentType"/> + <xsd:element name="fault" type="tns:FaultType"/> + <xsd:element name="from" type="xsd:string"/> + <xsd:complexType name="ArticleType"> + <xsd:sequence> + <xsd:element name="id" type="xsd:string"/> + <xsd:element name="title" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="CommentType"> + <xsd:sequence> + <xsd:element name="author" type="xsd:string"/> + <xsd:element name="content" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + <xsd:complexType name="FaultType"> + <xsd:sequence> + <xsd:element name="timestamp" type="xsd:string"/> + <xsd:element name="details" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:schema> + </wsdl:types> + + <wsdl:message name="IdMessage"> + <wsdl:part name="timestamp" type="xsd:string"/> + <wsdl:part name="from" element="tns:from"/> + <wsdl:part name="articleId" type="xsd:string"/> + </wsdl:message> + <wsdl:message name="ArticleMessage"> + <wsdl:part name="timestamp" type="xsd:string"/> + <wsdl:part name="article" element="tns:article"/> + </wsdl:message> + <wsdl:message name="PUTRequest"> + <wsdl:part name="articleId" type="xsd:string"/> + <wsdl:part name="article" element="tns:article"/> + </wsdl:message> + <wsdl:message name="CommentRequest"> + <wsdl:part name="articleId" type="xsd:string"/> + <wsdl:part name="comment" element="tns:comment"/> + </wsdl:message> + <wsdl:message name="UpdateFault"> + <wsdl:part name="faultDetails" element="tns:fault"/> + </wsdl:message> + <wsdl:message name="NoPartMessage"/> + + + <wsdl:portType name="BlogPortType"> + <wsdl:operation name="doGET"> + <wsdl:input message="tns:IdMessage"/> + <wsdl:output message="tns:ArticleMessage"/> + </wsdl:operation> + <wsdl:operation name="doDELETE"> + <wsdl:input message="tns:IdMessage"/> + <wsdl:output message="tns:NoPartMessage"/> + </wsdl:operation> + <wsdl:operation name="doPUT"> + <wsdl:input message="tns:PUTRequest"/> + <wsdl:output message="tns:NoPartMessage"/> + <wsdl:fault name="UpdateException" message="tns:UpdateFault"/> + </wsdl:operation> + <wsdl:operation name="doPOST"> + <wsdl:input message="tns:CommentRequest"/> + <wsdl:output message="tns:NoPartMessage"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="binding" type="tns:BlogPortType"> + <wsdl:operation name="doGET"> + <http:operation location=""/> + <odex:binding verb="GET"/> + <wsdl:input> + <http:urlReplacement/> + <!-- a part mapped to a non-standard header --> + <odex:header name="TimestampHeader" part="timestamp"/> + <odex:header name="From" part="from"/> + </wsdl:input> + <wsdl:output> + <mime:content type="text/xml" part="article"/> + <!-- a part mapped to a non-standard header --> + <odex:header name="TimestampHeader" part="timestamp"/> + </wsdl:output> + </wsdl:operation> + <wsdl:operation name="doDELETE"> + <http:operation location=""/> + <odex:binding verb="DELETE"/> + <wsdl:input> + <http:urlReplacement/> + <odex:header name="TimestampHeader" part="timestamp"/> + <!-- a static value mapped to a standard header --> + <odex:header name="User-Agent" value="MyKillerApp"/> + </wsdl:input> + <wsdl:output/> + </wsdl:operation> + <wsdl:operation name="doPUT"> + <http:operation location=""/> + <odex:binding verb="PUT"/> + <wsdl:input> + <http:urlReplacement/> + <mime:content type="text/xml" part="article"/> + </wsdl:input> + <wsdl:output/> + <!-- fault binding --> + <wsdl:fault name="UpdateException"> + <!-- name attribute is optional --> + <!--<odex:fault name="UpdateException"/>--> + <odex:fault/> + </wsdl:fault> + </wsdl:operation> + <wsdl:operation name="doPOST"> + <http:operation location=""/> + <odex:binding verb="POST"/> + <wsdl:input> + <http:urlReplacement/> + <mime:content type="application/x-www-form-urlencoded" /> + </wsdl:input> + <wsdl:output/> + </wsdl:operation> + </wsdl:binding> + + <wsdl:service name="BlogService"> + <wsdl:port name="BlogPort" binding="tns:binding"> + <http:address location="http://localhost:7070/HttpBindingTest/BlogService/article/{articleId}"/> + </wsdl:port> + </wsdl:service> +</wsdl:definitions> http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/deploy.xml ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/deploy.xml b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/deploy.xml new file mode 100644 index 0000000..fb64af5 --- /dev/null +++ b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/deploy.xml @@ -0,0 +1,34 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03" + xmlns:pns="http://ode/bpel/unit-test" + xmlns:wns="http://ode/bpel/unit-test.wsdl" + xmlns:dns="http://ode/bpel/test/blog"> + + + <process name="pns:http-binding-ext-POST"> + <active>true</active> + <provide partnerLink="helloPartnerLink"> + <service name="wns:HelloService" port="HelloPort"/> + </provide> + <invoke partnerLink="blogPartnerLink"> + <service name="dns:BlogService" port="BlogPort"/> + </invoke> + </process> +</deploy> http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.bpel ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.bpel b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.bpel new file mode 100644 index 0000000..a7898be --- /dev/null +++ b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.bpel @@ -0,0 +1,110 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<process name="http-binding-ext-POST" + targetNamespace="http://ode/bpel/unit-test" + xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable" + xmlns:tns="http://ode/bpel/unit-test" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:test="http://ode/bpel/unit-test.wsdl" + xmlns:dummy="http://ode/bpel/test/blog" + queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0" + expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0"> + + <import location="http-binding-ext-POST.wsdl" + namespace="http://ode/bpel/unit-test.wsdl" + importType="http://schemas.xmlsoap.org/wsdl/"/> + + <partnerLinks> + <partnerLink name="helloPartnerLink" + partnerLinkType="test:HelloPartnerLinkType" myRole="me"/> + <partnerLink name="blogPartnerLink" + partnerLinkType="test:BlogLinkType" partnerRole="you"/> + </partnerLinks> + + <variables> + <variable name="inputVar" messageType="test:HelloMessage"/> + <variable name="outputVar" messageType="test:HelloMessage"/> + <variable name="commentMsg" messageType="dummy:CommentRequest"/> + <variable name="noPartMsg" messageType="dummy:NoPartMessage"/> + <variable name="myvar" type="xsd:string"/> + </variables> + <sequence> + <receive name="start" partnerLink="helloPartnerLink" portType="test:HelloPortType" + operation="hello" variable="inputVar" createInstance="yes"/> + + <!-- Initialize output var --> + <assign> + <copy> + <from>'What a success!'</from> + <to>$outputVar.TestPart</to> + </copy> + </assign> + + <!-- Prepare the input message --> + <assign> + <copy> + <from>string(round(seconds-from-dateTime(current-dateTime())))</from> + <to>$commentMsg.articleId</to> + </copy> + <copy> + <from>string(round(seconds-from-dateTime(current-dateTime())))</from> + <to>$commentMsg.articleId</to> + </copy> + <copy> + <from> + <literal> + <dummy:comment> + <dummy:author>Voltaire</dummy:author> + <dummy:content>When it is a question of money, everybody is of the same religion.</dummy:content> + </dummy:comment> + </literal> + </from> + <to>$commentMsg.comment</to> + </copy> + </assign> + + <invoke partnerLink="blogPartnerLink" portType="dummy:BlogPortType" + operation="doPOST" inputVariable="commentMsg" outputVariable="noPartMsg"/> + + <!-- Check the Location Header --> + <assign> + <copy> + <from variable="noPartMsg" header="Location"/> + <to>$myvar</to> + </copy> + </assign> + + <if> + <condition>string-length($myvar) != 0</condition> + <empty/> + <else> + <assign> + <copy> + <from>'Empty Location Header received.'</from> + <to>$outputVar.TestPart</to> + </copy> + </assign> + </else> + </if> + + <reply name="end" partnerLink="helloPartnerLink" portType="test:HelloPortType" + operation="hello" variable="outputVar"/> + </sequence> + +</process> http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.wsdl ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.wsdl b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.wsdl new file mode 100644 index 0000000..c79427e --- /dev/null +++ b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/http-binding-ext-POST.wsdl @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<wsdl:definitions + targetNamespace="http://ode/bpel/unit-test.wsdl" + xmlns="http://schemas.xmlsoap.org/wsdl/" + xmlns:tns="http://ode/bpel/unit-test.wsdl" + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" + xmlns:dummy="http://ode/bpel/test/blog" + xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype"> + + <wsdl:import namespace="http://axis2.ode.apache.org" + location="Blog.wsdl"/> + + <wsdl:message name="HelloMessage"> + <wsdl:part name="TestPart" type="xsd:string"/> + </wsdl:message> + + <wsdl:portType name="HelloPortType"> + <wsdl:operation name="hello"> + <wsdl:input message="tns:HelloMessage" name="TestIn"/> + <wsdl:output message="tns:HelloMessage" name="TestOut"/> + </wsdl:operation> + </wsdl:portType> + + <wsdl:binding name="HelloSoapBinding" type="tns:HelloPortType"> + <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> + <wsdl:operation name="hello"> + <soap:operation soapAction="" style="rpc"/> + <wsdl:input> + <soap:body + namespace="http://ode/bpel/unit-test.wsdl" + use="literal"/> + </wsdl:input> + <wsdl:output> + <soap:body + namespace="http://ode/bpel/unit-test.wsdl" + use="literal"/> + </wsdl:output> + </wsdl:operation> + </wsdl:binding> + <wsdl:service name="HelloService"> + <wsdl:port name="HelloPort" binding="tns:HelloSoapBinding"> + <soap:address location="http://localhost:8888/ode/processes/helloWorld"/> + </wsdl:port> + </wsdl:service> + + <plnk:partnerLinkType name="HelloPartnerLinkType"> + <plnk:role name="me" portType="tns:HelloPortType"/> + </plnk:partnerLinkType> + <plnk:partnerLinkType name="BlogLinkType"> + <plnk:role name="you" portType="dummy:BlogPortType"/> + </plnk:partnerLinkType> +</wsdl:definitions> http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/testRequest.soap ---------------------------------------------------------------------- diff --git a/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/testRequest.soap b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/testRequest.soap new file mode 100644 index 0000000..afc8fb7 --- /dev/null +++ b/axis2-war/src/test/resources/TestHttpBindingExt_POST_FORM_URL_ENCODED/testRequest.soap @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> + <!-- test soap message --> + <SOAP-ENV:Body> + <ns1:hello xmlns:ns1="http://ode/bpel/unit-test.wsdl"> + <TestPart xmlns="">100</TestPart> + </ns1:hello> + </SOAP-ENV:Body> +</SOAP-ENV:Envelope> http://git-wip-us.apache.org/repos/asf/ode/blob/ff155256/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java ---------------------------------------------------------------------- diff --git a/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java b/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java index 68dd786..87889a4 100644 --- a/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java +++ b/axis2/src/main/java/org/apache/ode/axis2/httpbinding/HttpMethodConverter.java @@ -153,11 +153,12 @@ public class HttpMethodConverter { if (useUrlReplacement) { // insert part values in the url completeUri = new UrlReplacementTransformer().transform(completeUri, partValues); - } else if (useUrlEncoded) { + } + if (useUrlEncoded) { // encode part values encodedParams = new URLEncodedTransformer().transform(partValues); } - + log.debug("completeUri {}, encodedParams {}",completeUri,encodedParams); // 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.
