I am new to Mulesfot and Mule4 and I am still trying to understand how things works here. Check the following image:
On the first processor I am calling a Salesforce URL and getting an XML back which I am transforming to a JSON in the second processor, there I am storing/outputting the result to a variable SalesforceResponse
and later on the third one I am calling a subflow which stores some values on the database. Until that point everything works as expected. The problem comes once I try to access the variable SalesforceResponse
in the last processor which I need to get some values as the serverURL
for example. Currently I am getting the following error:
Message : Cannot open a new cursor on a closed stream.
Element : SalesforceFlow/processors/3 @ salesforcefulfillment:salesforcefulfillment.xml:340 (Transform Message)
Element XML : <ee:transform doc:name="Transform Message" doc:id="bea5898f-5aa8-4835-8e9d-fa1fd165d6d2">
<ee:message></ee:message>
<ee:variables>
<ee:set-variable variableName="SalesforceServerUrl">%dw 2.0
import * from dw::core::URL
var urlComposition = parseURI(vars.SalesforceResponse.serverUrl)
output text/plain
---
log("Houston, we have a problem.")</ee:set-variable>
</ee:variables>
</ee:transform>
Error type : MULE:UNKNOWN
What does error even means? I would expect to be able to access a "session" variable all over the places along the flow without having issues or I can't for some reason that I am not aware of?
Here is the XML definition for the image above:
<sub-flow name="SalesforceFlow" doc:id="237910c7-38c7-42bb-969b-63d6ff03bdaa">
<http:request method="POST" doc:name="Get SF SessionId" doc:id="37908152-700d-4c0e-9b52-b0de25f50fdf" config-ref="HTTP_Request_Salesforce" path="/services/Soap/u/44.0" sendCorrelationId="ALWAYS" outputMimeType="application/xml">
<http:body><![CDATA[#[%dw 2.0
ns soapenv http://schemas.xmlsoap.org/soap/envelope/
ns urn urn:partner.soap.sforce.com
output application/xml
---
soapenv#Envelope: {
soapenv#Body: {
urn#login: {
urn#username: p('SalesforceUsername'),
urn#password: p('SalesforcePassword')
}
}
}]]]>
</http:body>
</http:request>
<ee:transform doc:name="Transform Message" doc:id="b58ed3bd-7d74-4ad1-961f-8bab7a2ff128">
<ee:message>
</ee:message>
<ee:variables>
<ee:set-variable variableName="SalesforceResponse" ><![CDATA[ %dw 2.0
output application/json
ns soap http://schemas.xmlsoap.org/soap/envelope/
---
payload.soap#Envelope.soap#Body.loginResponse.result]]></ee:set-variable>
</ee:variables>
</ee:transform>
<flow-ref doc:name="Log Salesforce Response" doc:id="48326f18-a89b-49b2-ab96-ef2fe7214aaf" name="IntegrationFabricLogsFlow"/>
<ee:transform doc:name="Transform Message" doc:id="bea5898f-5aa8-4835-8e9d-fa1fd165d6d2" >
<ee:message >
</ee:message>
<ee:variables >
<ee:set-variable variableName="SalesforceServerUrl" ><![CDATA[%dw 2.0
import * from dw::core::URL
var urlComposition = parseURI(vars.SalesforceResponse.serverUrl)
output text/plain
---
log("Houston, we have a problem.")]]></ee:set-variable>
</ee:variables>
</ee:transform>
</sub-flow>
Can I get some help to understand how variable definition/access does work in Mule4?