[mule-user] How to read response from HTTP outbound endpoint...

2,670 views
Skip to first unread message

ohhenry

unread,
Dec 5, 2011, 12:01:50 PM12/5/11
to us...@mule.codehaus.org
I have....

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" />
<object-to-string-transformer />

<custom-transformer class="com.worldpay.transformer.MyTransformer" />

<enricher target="#[variable:test]">
<jdbc:outbound-endpoint queryKey="merchantMap" exchange-pattern="request-response" />
</enricher>

<custom-transformer class="com.worldpay.transformer.MyTransformer2" />


<response>
<http:http-response-to-string-transformer />
<custom-transformer class="com.worldpay.transformer.TestTransformer" />
</response>


<http:outbound-endpoint exchange-pattern="request-response" host="xxx.xxx.xxx.xxxx" port="80" path="path" method="POST"/>

So basically I want to read the body of the HTTP output convert it and pass it back to the client as HTTP response.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


David Dossot

unread,
Dec 5, 2011, 12:13:37 PM12/5/11
to us...@mule.codehaus.org
And what is the question?

ohhenry

unread,
Dec 5, 2011, 1:03:28 PM12/5/11
to us...@mule.codehaus.org
My TestTransformer receives

DEBUG 2011-12-05 12:07:34,682 [connector.http.mule.default.receiver.03] com.worldpay.transformer.TestTransformer: Object after transform:
org.mule.DefaultMuleMessage
{
id=a024e04a-1f63-11e1-975a-c997e9e65178
payload=org.mule.transport.http.ReleasingInputStream
correlationId=<not set>
correlationGroup=-1
correlationSeq=-1
encoding=UTF-8
exceptionPayload=<not set>

Message properties:
INVOCATION scoped properties:
INBOUND scoped properties:
Connection=true
Date=Mon, 05 Dec 2011 17:07:33 GMT
Keep-Alive=true
Server=Microsoft-IIS/6.0
X-Powered-By=ASP.NET
http.method=POST
http.request=http://mtldevtiis/stlink/ct/stlink.dll
http.status=200
http.version=HTTP/1.1
OUTBOUND scoped properties:
MULE_ENCODING=UTF-8
MULE_SESSION=rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wACnByb3BlcnRpZXN0AA9MamF2YS91dGlsL01hcDtMAA9zZWN1cml0eUNvbnRleHR0ACdMb3JnL211bGUvYXBpL3NlY3VyaXR5L1NlY3VyaXR5Q29udGV4dDt4cAF0ACRhMDFkZGI1Mi0xZjYzLTExZTEtOTc1YS1jOTk3ZTllNjUxNzhzcgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAMdwgAAAAQAAAAAHhwdAAHQXBhY3MzMHg=
SESSION scoped properties:
}

I thought by adding the http-response-to-string my test transformer would receive a String in the payload... further more I lose all my invocation variables that where set prior to calling the http end point.

David Dossot

unread,
Dec 5, 2011, 1:10:48 PM12/5/11
to us...@mule.codehaus.org
You need to use <object-to-string-transformer /> if you want to turn the HTTP response input stream into a String.

Regarding the message properties: they get lost because the HTTP response becomes the new context. If you want to keep them, perform the HTTP call via an enricher.

HTH
D.

ohhenry

unread,
Dec 5, 2011, 1:42:47 PM12/5/11
to us...@mule.codehaus.org
Hey David you are quite a helpufull guy! It worked... I figured the http-response-to-string would work but I guess not...

ohhenry

unread,
Dec 5, 2011, 2:02:18 PM12/5/11
to us...@mule.codehaus.org
Ok so I now i put an enricher around my endpoint...


<enricher target="#[variable:out]">
<http:outbound-endpoint exchange-pattern="request-response" host="xxx.xxx.xxx.xxx" port="80" path="path" method="POST">
<object-to-string />
</http:outbound-endpoint>
</enricher>


But my invocation variable is of type...

org.mule.transport.http.ReleasingInputStream

David Dossot

unread,
Dec 5, 2011, 2:11:52 PM12/5/11
to us...@mule.codehaus.org
What if you put:

<response>
  <object-to-string-transformer />
<response>

inside the http:outbound-endpoint?

ohhenry

unread,
Dec 5, 2011, 2:50:18 PM12/5/11
to us...@mule.codehaus.org
Thanks once more...
Reply all
Reply to author
Forward
0 new messages