wso2 Missing boundary in multipart/form-data POST - wso2

I'm trying to implement this scenario:
wso2Proxy sends POST to joao.php
joao.php gets id value and returns it.
if i call joao.php from a browser and a form with a field called id it works. If i do the same in WSO2 Proxy i get the php error Missing boundary in multipart/form-data POST.
I used TCPMon to analyse the calls and WSO2 sends Content-Type: multipart/form-data but no boundary.
Can someone point me in the right direction?
Here are the 2 calls:
From Browser:
POST /joao.php HTTP/1.1
Host: localhost:7590
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=----WebKitFormBoundarytcskUke6yP5MNOzt
Origin: http://localhost:7590
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8
Referer: http://localhost:7590/joao.php
Upgrade-Insecure-Requests: 1
DNT: 1
Content-Length: 135
Connection: keep-alive
------WebKitFormBoundarytcskUke6yP5MNOzt
Content-Disposition: form-data; name="id"
sd
------WebKitFormBoundarytcskUke6yP5MNOzt--
From WSO2 Proxy:
POST /joao.php HTTP/1.1
Content-Type: multipart/form-data
Content-Length: 264
Host: localhost:7590
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba
Content-Disposition: form-data; name="id"
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 8bit
teste123
--MIMEBoundary_4e039051f0592881a6551113d958f38436c2e8eef5b85bba--
I have the following commented sections on axis2.xml:
<!--messageFormatter contentType="multipart/form-data"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/-->
<!--messageBuilder contentType="multipart/form-data"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/-->
This is because if I enable them then the content gets posted as XML and not multipart/data.
As a result, these are the builders and formatters that are enabled for multipart/data:
<messageFormatter class="org.apache.axis2.transport.http.MultipartFormDataFormatter" contentType="multipart/form-data"/>
<messageBuilder class="org.apache.axis2.builder.MultipartFormDataBuilder" contentType="multipart/form-data"/>
Here is the proxy configuration I am using:
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
transports="http https"
startOnLoad="true">
<description/>
<target>
<inSequence>
<payloadFactory media-type="xml">
<format>
<params xmlns="">
<id>teste123</id>
</params>
</format>
<args/>
</payloadFactory>
<property name="messageType" value="multipart/form-data" scope="axis2"/>
<property name="DISABLE_CHUNKING"
value="true"
scope="axis2"
type="STRING"/>
<log level="full"/>
<send>
<endpoint>
<http method="POST" uri-template="http://localhost:7590/joao.php"/>
</endpoint>
</send>
<log level="full"/>
</inSequence>
</target>
</proxy>

If you're only sending text values as form data, you can use application/x-www-form-urlencoded instead of form-data.
See http://isharapremadasa.blogspot.com/2014/09/sending-form-data-through-wso2-esb-with.html

This is a bug. Will be fixed in next release.

I was able to resolve the issue by changing the proxy service to the following.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="testeSendFile"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<outSequence>
<property name="OUT_ONLY" value="true"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://localhost:8080/upload"/>
</endpoint>
</target>
<description/>
</proxy>
For more detailed information refer to the following bolg.
Ushani Balasooriya's Blog
Here is the sample request

Related

WSO2 Multipart Binary Passthrough and MultipartFormData

We are currently using WSO EI 6.4 as ESB.
We made the configuration to get the behaviour "Binary Passthrough" in axis2.xml for one carbon application
<messageBuilder contentType="multipart/form-data" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<messageFormatter contentType="multipart/form-data" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
But now, we need to develop a new carbon application who need to create a multipart message.
and so we need to change the configuration to, as decribed in this article
<messageBuilder contentType="multipart/form-data" class="org.apache.axis2.builder.MultipartFormDataBuilder" />
<messageFormatter contentType="multipart/form-data" class="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
But if we do that, we will lose the "Binary Passthrough" adn broke the first carbon app.
Is there a possiblitiy to override the messageBuilder and messageFormatter just for one carbon application?
Thank you
Solution
With the help of #tmoasz i was able to solve this issue.
Here the full solution
<inSequence>
<!--Extract value from Json-->
<property name="Data1" expression="json-eval($.Data1)"/>
<property name="Data2" expression="json-eval($.Data2)"/>
<property name="File1" expression="json-eval($.File1)"/>
<!-- remove body and set MessageBuilder
if body not removed, MultipartFormDataFormatter is not call
-->
<script language="js">
mc.getEnvelope().getBody().getFirstElement().detach();
</script>
<builder>
<messageBuilder contentType="multipart/form-data"
class="org.apache.axis2.builder.MultipartFormDataBuilder"
formatterClass="org.apache.axis2.transport.http.MultipartFormDataFormatter"/>
</builder>
<payloadFactory media-type="xml">
<format>
<root xmlns="">
<metadata xmlns="http://org.apache.axis2/xsd/form-data"
filename="key1"
name="key1">$1</metadata>
<!-- content is decode from base64-->
<file xmlns="http://org.apache.axis2/xsd/form-data"
filename="file1.1"
name="file1.1"
content-type="application/xml">$3</file>
<!-- content is not changed-->
<metadata xmlns="http://org.apache.axis2/xsd/form-data"
name="file1.2"
filename="file1.2"
content-type="application/xml">$3</metadata>
</root>
</format>
<args>
<arg expression="get-property('Data1')"/>
<arg expression="get-property('Data2')"/>
<arg expression="get-property('File1')"/>
</args>
</payloadFactory>
<!--set messageType to trigger multiPart Formater -->
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<!--remove ContentType to force generate header content-type with boundary information -->
<property name="ContentType" scope="axis2" action="remove"/>
<send>
<endpoint>
<http method="post" uri-template="http://127.0.0.1:3000/mulitPart/wso2">
<suspendOnFailure>
<initialDuration>-1</initialDuration>
<progressionFactor>-1</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
</markForSuspension>
</http>
</endpoint>
</send>
</inSequence>
Curl for test
curl --location --request POST 'http://127.0.0.1:8280/outgoing-mail' \
--header 'Content-Type: application/json' \
--data-raw '{
"Data1": "Value1",
"Data2": "Value2",
"File1" : "PHhtbD4gICAKICAgIDxoZWxsbz5TdGFjazwvaGVsbG8+CjwveG1sPg=="
}'
Multipart Generated
--MIMEBoundary_dfa6d9a4ea9eee573969c1fae03dd6667159a66375689ec7
Content-Disposition: form-data; name="key1"; filename="key1"
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: binary
Value1
--MIMEBoundary_dfa6d9a4ea9eee573969c1fae03dd6667159a66375689ec7
Content-Disposition: form-data; name="file1.1"; filename="file1.1"
Content-Type: application/pdf; charset=ISO-8859-1
Content-Transfer-Encoding: binary
<xml>
<hello>Stack</hello>
</xml>
--MIMEBoundary_dfa6d9a4ea9eee573969c1fae03dd6667159a66375689ec7
Content-Disposition: form-data; name="file1.2"; filename="file1.2"
Content-Type: application/pdf; charset=ISO-8859-1
Content-Transfer-Encoding: binary
PHhtbD4gICAKICAgIDxoZWxsbz5TdGFjazwvaGVsbG8+CjwveG1sPg==
--MIMEBoundary_dfa6d9a4ea9eee573969c1fae03dd6667159a66375689ec7--
Maybe the BuilderMediator can do that, what you would to achieve.
Checkout this: Builder+Mediator documentation.

WSO2 ESB proxy Log mediator properties

I'd like to log (and ideally correlate) incoming and outgoing messages with at minimum the following properties:
Date/Time
Client Address (IP, name optional)
Method
I can get this working for incoming messages using the following but for the outgoing message (back to the client), it returns null.
get-property('axis2', 'REMOTE_ADDR')
Incoming
[2016-01-18 13:18:46,339] INFO - LogMediator To: /services/UserService, WSAction: http://tempuri.org/UserService/Login, SOAPAction: http://tempuri.org/UserService/Login, MessageID: urn:uuid:3e4b7f91-cab0-4294-a013-3c837f6695a0, Direction: request, REMOTE_ADDR: = 172.xx.xx.xx
Outgoing
[2016-01-18 13:18:46,505] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:8de88329-3968-4edc-8617-352fbcb5480b, Direction: response, REMOTE_ADDR: = null
It's also not possible to correlate the incoming and outgoing messages as the MessageId changes (I guess predictably).
Would it be necessary to set a custom property on the inbound side to correlate this?
AFAIK, you need set a custom property on the inSequence.
I tested this localy and for the below proxy I was able to get REMOTE_ADDR: = 172.xx.xx.xx for both Incoming and outgoing messages.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="test"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="client-add" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
<send>
<endpoint>
<address uri="http://www.mocky.io/v2/569cac78110000dc24ce7614"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
<log level="custom">
<property name="REMOTE_ADDR :" expression="get-property('client-add')"/>
</log>
</outSequence>
</target>
<description/>
</proxy>
For more information on Retriving clientIP/Host within the sequence in Synapse please refer this documentation.
For more information on How to get client IP from out going requests of WSO2 Elastic load balancer please refer this documentation
Hope this information will help you.
Thanks
Yes, you need to add a custom property mediator to the inSequence to get and save the value of IP address of the incoming request. Then by adding log mediators to both inSequence and outSequence, you will be able to see that the IP address is preserved in outgoing message as well.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="oneProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="ip" expression="get-property('axis2', 'REMOTE_ADDR')"/>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:8290/services/echo"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="full">
<property name="REMOTE_ADDR :" expression="get-property('ip')"/>
</log>
<send/>
</outSequence>
</target>
<description/>
</proxy>
Hope this may help you...

How to convert (JSON toXML) request and Response(XML to JSON) to call an external Soap Service

i am new to wso2.. My requirement is
1) I want to transform incoming JSON request into XML format
2) Send that XML request to an external SOAP service
3) Response will get as XML and need to convert it into JSON format
Did somebody ever did that? If so, could you please share how you did?
I have the below configuration for a PROXY service
`<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="CelsiusToFahrenheitService"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="text/xml" scope="axis2"/>
<property name="Proxy-Authorization"
expression="fn:concat('Basic', base64Encode('INDIA\username:pwd'))"
scope="transport"/>
<property name="POST_TO_URI" value="true" scope="axis2"/>
<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>
<header name="Action"
value="http://www.w3schools.com/webservices/CelsiusToFahrenheit"/>
<send>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx"
format="soap11"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="messageType" value="text/xml" scope="axis2"/>
<send/>
</outSequence>
</target>
<description/>
</proxy>`
XML Request
<CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/">
<Celsius>20</Celsius>
</CelsiusToFahrenheit>
XMl Response
<CelsiusToFahrenheitResponse xmlns="http://www.w3schools.com/webservices/">
<CelsiusToFahrenheitResult>68</CelsiusToFahrenheitResult>
</CelsiusToFahrenheitResponse>
Need to send REQUEST as JSON and RESPOSNE also get as JSON
Can anyone please help me the scenario
How to use ScriptMediator to do the above proxy service. I have got sample from here (https://docs.wso2.org/display/ESB481/Sample+441%3A+Converting+JSON+to+XML+Using+JavaScript)
I have did my configuration like this (Don't know is it correct or not)
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonToXMLProxy"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<script language="js">var cel= mc.getPayloadJSON().CelsiusToFahrenheit.Celsius.toString();
mc.setPayloadXML(
<CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/">
<Celsius>{cel}</Celsius>
</CelsiusToFahrenheit>);</script>
<property name="messageType" value="text/xml" scope="axis2"/>
<log level="full"/>
</inSequence>
<outSequence>
<log level="full"/>
<property name="messageType" value="text/xml" scope="axis2"/>
<send/>
</outSequence>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx"
format="soap11"/>
</endpoint>
</target>
<description/>
</proxy>
But i am getting the exception like this
`[2014-03-20 18:19:02,391] INFO - LogMediator To: /services/JsonToXMLProxy.JsonToXMLProxyHttpEndpoint, MessageID: urn:uuid:a2eeeb26-94e1-4ed1-a3f9-79f1d1461821, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><CelsiusToFahrenheit xmlns="http://www.w3schools.com/webservices/"><Celsius>20</Celsius></CelsiusToFahrenheit></soapenv:Body></soapenv:Envelope>
[2014-03-20 18:19:03,130] WARN - ClientHandler Received an unexpected response - of content type : text/html and status code : 411 with reason : Length Required For : 172.26.40.214:8080 For Request : Axis2Request [Message ID : urn:uuid:39d47344-f74c-4ec5-855b-5eb90e178b6d] [Status Completed : true] [Status SendingCompleted : true]
[2014-03-20 18:19:04,133] INFO - BuilderUtil OMException in getSOAPBuilder
org.apache.axiom.om.OMException: SOAP message MUST NOT contain a Document Type Declaration(DTD)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createDTD(StAXSOAPModelBuilder.java:462)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:282)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:659)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:198)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:146)
at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:253)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
[2014-03-20 18:19:04,137] INFO - BuilderUtil Remaining input stream :[]
[2014-03-20 18:19:04,137] WARN - ClientWorker Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)
[2014-03-20 18:19:04,153] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:39d47344-f74c-4ec5-855b-5eb90e178b6d, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><soapenv:Fault><faultcode>411</faultcode><faultstring>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)</faultstring><detail>Unexpected response received. HTTP response code : 411 HTTP status : Length Required exception : SOAP message MUST NOT contain a Document Type Declaration(DTD)</detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>`
Please help me for this issue
Thanks in advance.
you could use this example using de payloadfactory mediator to build the messages, it work for me in your scenario:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="JsonToXMLProxy"
transports="https http local"
startOnLoad="true"
trace="disable">
<description/>
<target>
<endpoint>
<address uri="http://www.w3schools.com/webservices/tempconvert.asmx" format="soap11"/>
</endpoint>
<inSequence>
<log>
<property name="TEMPERATURA_ENTRADA" expression="json-eval($.celsius)"/>
</log>
<payloadFactory media-type="xml">
<format>
<web:CelsiusToFahrenheit xmlns:web="http://www.w3schools.com/webservices/">
<web:Celsius>$1</web:Celsius>
</web:CelsiusToFahrenheit>
</format>
<args>
<arg evaluator="json" expression="$.celsius"/>
</args>
</payloadFactory>
<header name="Action"
value="http://www.w3schools.com/webservices/CelsiusToFahrenheit"/>
</inSequence>
<outSequence>
<log>
<property xmlns:p="http://www.w3schools.com/webservices/"
name="TEMPERATURA_SALIDA"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</log>
<payloadFactory media-type="json">
<format>
"Temperatura" : {
"EnFahrenheit" : $1
}
</format>
<args>
<arg xmlns:p="http://www.w3schools.com/webservices/"
evaluator="xml"
expression="//p:CelsiusToFahrenheitResponse/p:CelsiusToFahrenheitResult"/>
</args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
</target>
</proxy>

WSO2 ESB logging in proxy

I have simple proxy with send messages to some url. I would like to know when something is send through proxy, and when response is send back.
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SynchronizeService" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="simple"/>
<send>
<endpoint key="SynchronizeServiceEndpoint"/>
</send>
</inSequence>
<outSequence>
<log level="simple"/>
<send/>
</outSequence>
</target>
</proxy>
I added log mediator but the problem is, it don't log any information which allow to connect request and response. So example log looks like:
[2013-06-03 15:38:07,914] INFO - LogMediator To: http://esb-ip:9763/services/SynchronizeService, WSAction: http://test.pl/WebService/getWorkPlan, SOAPAction: http://test.pl/WebService/getWorkPlan, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:36b60af3-dc30-4004-a239-26523774f52b, Direction: request
[2013-06-03 15:38:08,016] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:8f753934-c64a-4276-a916-dceaeda3def0, Direction: response
In logged response there is no information about SOAPAction, messageIds are different. How can I connect request with response in logs? I would like to known when response was send. How can I do this?
You did a simple log, which will log very basic info about the message. Do a log level=full, that will log the full message which is passed through the system
I didn't know that is is possible to assign variables in input Sequence and use them in output Sequence. I assign messageId from input sequence and log it in output. My proxy after changes looks like:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="SynchronizeService" transports="https http" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="simple"/>
<property name="requestSysDate" expression="get-property('SYSTEM_DATE')" scope="default" type="STRING"/>
<property name="requestMsgId" expression="get-property('MessageID')" scope="default" type="STRING"/>
<filter xmlns:procsyn="http://test.pl/WebService/Synchronize" xpath="//procsyn:getWorkPlanIn">
<property name="requestMethod" value="getWorkPlan" scope="default" type="STRING"/>
</filter>
<send>
<endpoint key="SynchronizeServiceEndpoint"/>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="proxyName" value="SynchronizeService"/>
<property name="requestMethod" expression="get-property('requestMethod')"/>
<property name="requestSysDate" expression="get-property('requestSysDate')"/>
<property name="requestMsgId" expression="get-property('requestMsgId')"/>
</log>
<send/>
</outSequence>
</target>
</proxy>

Transform response to plain-text using wso2 esb 4.0.6

I'm new to web-service and somehow I have created a simple web-service over http/https using wso2 esb 4.0.6. Now my requirement is to remove the tag from response i.e. i need plain text in response, below code snippets will give u a brief idea of my requirement.
<case regex="POST">
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<enrich>
<source type="inline" clone="true">
<success xmlns="">Your request for subscription is being processed.</success>
</source>
<target type="body"/>
</enrich>
<header name="To" action="remove"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="ContentType" value="text/plain" scope="axis2"/>
</case>
I'm able to get the below response <success>Your request for subscription is being processed.</success>
I just want to remove the <success> </success> tags from the response.
Thanks in advance
May be this is bit late, but I too have came across this recently, and here's how you can make it work.
Make sure in ESB/repository/conf/axis2/axis2.xml plainTextFormatter is enabled.
In your proxy service set 'messageType' property as shown below
Add a payload text element. Please refer to the out sequence of the sample proxy service given below
<outSequence>
<payloadFactory>
<format>
<ms11:text xmlns:ms11="http://ws.apache.org/commons/ns/payload">$1</ms11:text>
</format>
<args>
<arg xmlns:ns="http://www.wso2.org/types" expression="$body/ns:greetResponse/return/text()"/>
</args>
</payloadFactory>
<property name="messageType" value="text/plain" scope="axis2"/>
<log level="full"/>
<send/>
</outSequence>
In this scenario my response from the backend service (HelloService) is as follows.
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:greetResponse xmlns:ns="http://www.wso2.org/types">
<return>Hello World, Test !!!</return>
</ns:greetResponse>
</soapenv:Body>
</soapenv:Envelope>
See below the request and response for the GET request using curl command
curl -X GET "http://localhost:8280/services/TestProxy/greet?name=Test" -v
* About to connect() to localhost port 8280 (#0)
* Trying 127.0.0.1... connected
> GET /services/TestProxy/greet?name=Test HTTP/1.1
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8280
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; charset=UTF-8
< Server: WSO2 Carbon Server
< Vary: Accept-Encoding
< Date: Wed, 25 Sep 2013 06:08:21 GMT
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
* Closing connection #0
Hello World, Test !!!
Thanks
Sajith
Simply define the full envelope as inline source.
Eg:
<inSequence>
<enrich>
<source type="inline" clone="true">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body> Your request for subscription is being processed. </soapenv:Body>
</soapenv:Envelope>
</source>
<target type="envelope"/>
</enrich>
<header name="To" action="remove"/>
<property name="RESPONSE" value="true" scope="default" type="STRING"/>
<property name="Content-Type" value="text/plain" scope="transport" type="STRING"/>
<send/>
</inSequence>