0

我是 Mulesfot 和 Mule4 的新手,我仍在尝试了解这里的工作原理。检查下图:

子流

在第一个处理器上,我调用一个 Salesforce URL 并返回一个 XML,我在第二个处理器中将其转换为 JSON,在那里我将结果存储/输出到一个变量SalesforceResponse,稍后在第三个处理器上我调用一个子流在数据库中存储一些值。在那之前,一切都按预期工作。一旦我尝试访问最后一个处理器中的变量,问题就出现了,例如SalesforceResponse,我需要获取一些值。serverURL目前我收到以下错误:

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

错误甚至意味着什么?我希望能够在流程中的所有位置访问“会话”变量而不会出现问题,或者由于某种我不知道的原因我不能访问?

这是上图的 XML 定义:

<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>

我可以得到一些帮助来了解变量定义/访问在 Mule4 中是如何工作的吗?

4

0 回答 0