Friday, 23 August 2013

In Mule how could I log the http response without changing the original output stream

In Mule how could I log the http response without changing the original
output stream

My Mule will do a HTTP call and response to my client, I want to log the
HTTP call result, like status code and response body. At first I log the
#[payload], but it's a stream, I know <object-to-string-transformer/>
works, but I don't want to change the response, so I put the transformer
into an enricher, but the result is still changed, why?
My code:
<http:outbound-endpoint exchange-pattern="request-response"
address="http://#[payload]" doc:name="Call Service in Pool"/>
<enricher source="#[payload]" target="#[flowVars['responseBody']]"
doc:name="Message Enricher">
<object-to-string-transformer doc:name="Object to String"/>
</enricher>
<logger level="INFO" doc:name="Log Response" message="response, http
status: #[message.inboundProperties['http.status']], body:
#[flowVars['responseBody']], org: #[payload]"/>
Log output:
org.mule.api.processor.LoggerMessageProcessor: response, http status: 200,
body: {"groupId":"group1", "formParam":"null"}, org:
org.mule.transport.http.ReleasingInputStream@51dfd9b8
Client receives no body:
HTTP/1.1 200 OK
Content-Type: application/json
Date: Sat, 24 Aug 2013 10:55:49 +0800
Server: Mule EE Core Extensions/3.4.0
X-MULE_SESSION:
rO0ABXNyACNvcmcubXVsZS5zZXNzaW9uLkRlZmF1bHRNdWxlU2Vzc2lvbi7rdtEW7GGKAwAEWgAFdmFsaWRMAA1mbG93Q29uc3RydWN0dAAmTG9yZy9tdWxlL2FwaS9jb25zdHJ1Y3QvRmxvd0NvbnN0cnVjdDtMAAJpZHQAEkxqYXZhL2xhbmcvU3RyaW5nO0wAD3NlY3VyaXR5Q29udGV4dHQAJ0xvcmcvbXVsZS9hcGkvc2VjdXJpdHkvU2VjdXJpdHlDb250ZXh0O3hwAXB0ACRhZWFhODZjOS0wYzY4LTExZTMtYjhkZS0xNTQzZDIwNjFkNWZwc3IAJWphdmEudXRpbC5Db2xsZWN0aW9ucyRTeW5jaHJvbml6ZWRNYXAbc/kJS0s5ewMAAkwAAW10AA9MamF2YS91dGlsL01hcDtMAAVtdXRleHQAEkxqYXZhL2xhbmcvT2JqZWN0O3hwc3IAJG9yZy5tdWxlLnV0aWwuQ2FzZUluc2Vuc2l0aXZlSGFzaE1hcJ3R2e9nRc4AAwAAeHB3DD9AAAAAAAAQAAAAAHhxAH4ACXh4
X-MULE_ENCODING: UTF-8
Transfer-Encoding: chunked
Connection: close

No comments:

Post a Comment