0

I am new to Mulesfot and Mule4 and I am still trying to understand how things works here. Check the following image:

subflow

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?

ReynierPM
  • 17,594
  • 53
  • 193
  • 363
  • Looks like you are facing a bug here. Can you provide a sample app that reproduce the issue. – machaval Jun 06 '19 at 14:24
  • @machaval I don't think I can provide an app since this uses a lot of internal microservices but let me know what else I can do to help. I just discovered that the issue is not just only there, there are a few other process where the same issue happen :| – ReynierPM Jun 06 '19 at 14:30
  • what version of mule are you using? Can you try with 4.2 – machaval Jun 06 '19 at 19:48
  • I guess it's a bug, but try and assign a out put variable name for third process, that should reopen the stream. I.e assign a target name and target value as payload for the flow ref – Ven Jun 07 '19 at 10:17
  • @machaval I am using 4.1.5 not sure in how to upgrade to 4.2, any docs? – ReynierPM Jun 07 '19 at 15:37
  • @ReynierPM It should be there in the latest studio version. Make sure you have updated – machaval Jun 11 '19 at 12:21
  • @machaval then yes, I am in the latest Anypoint Studio version and is up to date – ReynierPM Jun 11 '19 at 13:02
  • Change the Mule version in the pom. – aled Jul 06 '19 at 16:36

0 Answers0