I am stuck with a minor issue .. There is My Mule flow .. I am passing a SOAP payload to an external webservice from a Message Enricher component and the Idea is to get a particular attribute value from the external webservice response and store that value in a flow variable ... Now, the response of the external webservice response is as follow :-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<getDesignationResponse xmlns="http://services.test.getDesignation.com/schema/MainData/V1">
<DesignationCodeResult>Junior Developer</DesignationCodeResult>
<Code>Success</Code>
</getDesignationResponse>
</soap:Body>
</soap:Envelope>
Now here is my flow :-
<flow name="testFlow1" doc:name="testFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test" doc:name="HTTP"/>
<set-payload value="<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.test.getDesignation.com/schema/MainData/V1"><soapenv:Header/><soapenv:Body><v1:getDesignationRequest><v1:DesignationCode>jd</v1:DesignationCode></v1:getDesignationRequest></soapenv:Body></soapenv:Envelope>" doc:name="Set Payload"/>
<enricher source="#[xpath://getDesignationResponse/DesignationCodeResult]" target="#[variable:myVal]" doc:name="Message Enricher">
<processor-chain doc:name="Processor Chain">
<http:outbound-endpoint exchange-pattern="request-response" method="POST" address="http://localhost:8090/designation" responseTimeout="100000" doc:name="HTTP" />
<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
<logger message="Value from response #[xpath://getDesignationResponse/DesignationCodeResult]" level="INFO" doc:name="Logger"/>
</processor-chain>
</enricher>
</flow>
Now you can see I am trying to store the value #[xpath://getDesignationResponse/DesignationCodeResult]
to the Flow Variable myVal ..
Now I am getting following exception :-
Exception stack is:
1. Expression Evaluator "header" with expression "invocation:myVal" returned null but a value was required. (org.mule.api.expression.RequiredValueException)
org.mule.expression.ExpressionUtils:235 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/expression/RequiredValueException.html)
2. Expression Evaluator "header" with expression "invocation:myVal" returned null but a value was required. (org.mule.api.expression.RequiredValueException). Message payload is of type: String (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.expression.RequiredValueException: Expression Evaluator "header" with expression "invocation:myVal" returned null but a value was required.
at org.mule.expression.ExpressionUtils.getPropertyInternal(ExpressionUtils.java:235)
at org.mule.expression.ExpressionUtils.getProperty(ExpressionUtils.java:85)
at org.mule.expression.ExpressionUtils.getProperty(ExpressionUtils.java:72)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
But I have put a logger inside the Enricher <logger message="Value from response #[xpath://getDesignationResponse/DesignationCodeResult]" level="INFO" doc:name="Logger"/>
and I am getting the value there ..
But I am unable to assign the extracted value in the Flow Variable using Enricher ...
Please help ..