Hi Pablo,
Thanks a lot for your response. Let me clarify what I'm trying to do.
I am trying to configure Mule ESB in such a way that it would take the following multipart POST request:
curl -F "foo=@file.json;type:application/json" -F "image=@photo.jpeg;type:image/jpeg" http://MyMuleIPAddress:8081/store
with, for instance, the following content for the file.json:
{
"root":
{
"field_1": "test1",
"field_2": "test2"
}
}
What I'd like to do is to get the first attachment called "foo" and parse it in the "choice" router to make sure that root/field_1 = test1. If that condition is true, I would move along the flow and would use the second attachment (the jpeg image) to store it into a repository.
I tried what you suggested with the expression transformer (see flow config below), but it throws an exception. Also, you suggested to put the json attachment as the payload to enable the json evaluator in the "choice" module, but in that case, can I still use the second attachment later ?
Here is the config:
<flow name="testJsonFlow1" doc:name="testJsonFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<expression-transformer evaluator="attachment" expression="#[attachment:foo]" returnSourceIfNull="true" doc:name="Expression"/>
<choice doc:name="Choice">
<when expression="root/field_1 = test1" evaluator="json">
<processor-chain>
<logger message="Success!" level="INFO" doc:name="Logger-success"/>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<logger message="Default to otherwise path..." level="INFO" doc:name="Logger-otherwise"/>
</processor-chain>
</otherwise>
</choice>
<echo-component doc:name="Echo"/>
</flow>
If I run the flow and send the curl command above, I get the following error:
ERROR 2012-02-11 14:17:37,974 [[naaas].connector.http.mule.default.receiver.04] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Expression Evaluator "attachment" with expression "#[attachment:foo]" returned null but a value was required. (org.mule.api.expression.RequiredValueException). Message payload is of type: ContentLengthInputStream
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Expression Evaluator "attachment" with expression "#[attachment:foo]" returned null but a value was required. (org.mule.api.expression.RequiredValueException)
org.mule.expression.MessageAttachmentExpressionEvaluator:55 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/RequiredValueException.html)
2. Expression Evaluator "attachment" with expression "#[attachment:foo]" returned null but a value was required. (org.mule.api.expression.RequiredValueException). Message payload is of type: ContentLengthInputStream (org.mule.api.transformer.TransformerMessagingException)
org.mule.transformer.AbstractTransformer:123 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transformer/TransformerMessagingException.html)
--------------------------------------------------------------------------------
Is there any error in my syntax? BTW, I run Mule 3.2.1 with MuleStudio:
version: 1.0.0
buildDate: 2012-01-20 09:37:24
Thanks a lot for the help.
Timothee
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email