在WSO2 EI / ESB中的脚本介体中处理有效负载

问题描述 投票:0回答:1

我的有效负载如下。 我需要在脚本介体中获取整个负载,并对该负载执行斜杠删除操作。我无法获得完整的有效负载,脚本中介器中仅获得一个json元素。谁能帮我吗?

RequestPayload:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject xmlns
="http://ws.apache.org/ns/synapse"><jsonValue xmlns="">"{\"transactionId\":null,\"timestamp\":\"2020-04-28 14:21:01\",\"OpportunityId\":\"0065500000Fz6EdAAJ\",\"message\":\"Insert/
Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvaJ8EAJ\"},\"Company\":\"N/A\",\"Email\":\"dunleavy2010@hotmail
.com\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Brendan\",\"LastName\":\"Dunleavy\",\"Id\":\"00Q5500000AvaJ8EAJ\",\"MobilePhone\":
\"+61 449 819 834\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue><jsonValue xmlns="">"{\"transactionId\":null,\"timestamp\":\"2020-04-28 14:21:01\",\"OpportunityId\":\"
0065500000Fz6EiAAJ\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvaJ3EAJ\"},\"Company\
":\"N/A\",\"Email\":\"[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"LastName\":\"Ross\",\"
Id\":\"00Q5500000AvaJ3EAJ\",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue><jsonValue xmlns="">"{\"transactionId\":null,\"timestamp\":
\"2020-04-28 14:21:04\",\"OpportunityId\":\"0065500000Fz6EnAAJ\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/so
bjects/Lead/00Q5500000AvaJDEAZ\"},\"Company\":\"N/A\",\"Email\":\"[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\
":\"Jaxon\",\"LastName\":\"Stevens\",\"Id\":\"00Q5500000AvaJDEAZ\",\"MobilePhone\":\"+61 423 927 100\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue></jsonObject></soape
nv:Body></soapenv:Envelope>

代理代码:

<proxy name="VBReadFromEmailBody" startOnLoad="true" transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
    <inSequence>
                <iterate expression="//jsonArray/jsonElement" id="LDVid" sequential="true">
                    <target>
                        <sequence>
                            <!-- Each jsonElement is pushed to SalesForce  -->
                            <sequence description="VBEmail_LDVNonQualifiedLead_Sequence" key="VBEmail_LDVNonQualifiedLead_Sequence"/>
                        </sequence>
                    </target>
                </iterate>
                <property name="Aggregated_Responses" scope="default">
                    <jsonObject/>
                </property>
                <aggregate id="LDVid">
                    <completeCondition>
                        <messageCount max="-1" min="-1"/>
                    </completeCondition>
                    <onComplete enclosingElementProperty="Aggregated_Responses" expression="$body/*[1]" xmlns:ns="http://org.apache.synapse/xsd">
                        <loopback/>
                    </onComplete>
                </aggregate>
     </inSequence>
    <outSequence>
        <log level="custom">
            <property name="======OUTSEQUENCE=======" value="CALLED"/>
        </log>
        <!-- Log to check aggregatedresponse  -->
        <log level="full"/>
                <property name="messageType" scope="axis2" type="STRING" value="application/json"/>
                <iterate expression="//jsonValue" sequential="true">
                    <target>
                        <sequence>
                            <property expression="json-eval($)" name="jsonString" scope="default" type="STRING"/>
                            <script language="js"><![CDATA[var log = mc.getServiceLog();        
var payload = mc.getProperty('jsonString').toString();log.info("script payload::::" + payload); payloadRemoveSlash = payload.replace('\\', '').replace('"{','{').replace('}"','}'); mc.setProperty('payloadRemoveSlash',payloadRemoveSlash);]]></script>
                        <log level="custom">
                          <property name=":: Body Inside payloadRemoveSlash::" expression="$ctx:payloadRemoveSlash"/>
                        </log>
                        <enrich>
            <source clone="true" type="inline">
                <test xmlns="">abc</test>
            </source>
            <target type="body"/>
        </enrich>
        <payloadFactory description="Form Salesforce Request" media-type="json">
            <format>$1</format>
            <args>
                <arg evaluator="xml" expression="get-property('payloadRemoveSlash')"/>
            </args>
        </payloadFactory>
                    <log level="custom">
                          <property name="After Enrich" expression="json-eval($.)"/>
                        </log>
                        </sequence>
                    </target>
                </iterate>
 </outSequence>
    <faultSequence>
        <log level="custom">
            <property description="ERROR_CODE" name="ERROR_CODE" scope="default" type="STRING" expression="get-property('ERROR_CODE')"/>
            <property description="ERROR_MESSAGE" name="ERROR_MESSAGE" scope="default" type="STRING" expression="get-property('ERROR_MESSAGE')/>
        </log>

     </faultSequence>
</target>

Wire Logs-1:

[2020-04-28 14:48:25,594] []  INFO - LogMediator LogText = Salesforce Request Uniqueidentifier:17132e6366d3d561,**, ======SF RequestPayload====== = {"getLead":{"Company":"N/A","Ema
    il":"[email protected]","Lead_Type__c":"Internet","LeadSource":"LDV i-Motor - Get a Quote","FirstName":"Brendan","LastName":"Dunleavy","MobilePhone":"+61 449 819 834"},"getT
    rade":[]}
    [2020-04-28 14:48:25,596] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "POST /services/apexrest/LeadIntegrationAPIHandler HTTP/1.1[\r][\n]"
    [2020-04-28 14:48:25,596] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Authorization: Bearer  00D550000000fgk!AR0AQALfr1npMosFbJQ.zn17zoWY2WnRXuFTNtBCPnkmo_WaCG9uvQJ68D.l.5NPI
    dIg0AUsv0yHmucn8ikq6inf74ePBFu3[\r][\n]"
    [2020-04-28 14:48:25,596] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
    [2020-04-28 14:48:25,597] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q04
    8=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,h3-T050=":443"; ma=2592000[\r][\n]"
    [2020-04-28 14:48:25,599] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Cache-Control: private, max-age=0, must-revalidate, no-transform[\r][\n]"
    [2020-04-28 14:48:25,600] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "ETag: "hicYA7eHlMWnqap7I2cx6HOrcNI/vfNEq8c2pcFW4FNGRTeNcH6yFic"[\r][\n]"
    [2020-04-28 14:48:25,600] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "X-Content-Type-Options: nosniff[\r][\n]"
    [2020-04-28 14:48:25,600] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Content-Security-Policy: frame-ancestors 'self'[\r][\n]"
    [2020-04-28 14:48:25,601] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Vary: Origin[\r][\n]"
    [2020-04-28 14:48:25,601] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Vary: X-Origin[\r][\n]"
    [2020-04-28 14:48:25,602] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Expires: Tue, 28 Apr 2020 09:18:05 GMT[\r][\n]"
    [2020-04-28 14:48:25,602] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "X-XSS-Protection: 1; mode=block[\r][\n]"
    [2020-04-28 14:48:25,602] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Content-Type: application/json[\r][\n]"
    [2020-04-28 14:48:25,603] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"
    [2020-04-28 14:48:25,603] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Host: vonbibra--vbdevmerge.my.salesforce.com[\r][\n]"
    [2020-04-28 14:48:25,603] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Connection: Keep-Alive[\r][\n]"
    [2020-04-28 14:48:25,604] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
    [2020-04-28 14:48:25,604] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
    [2020-04-28 14:48:25,604] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "dd[\r][\n]"
    [2020-04-28 14:48:25,605] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "{"getLead":{"Company":"N/A","Email":"[email protected]","Lead_Type__c":"Internet","LeadSource":"L
    DV i-Motor - Get a Quote","FirstName":"Brendan","LastName":"Dunleavy","MobilePhone":"+61 449 819 834"},"getTrade":[]}[\r][\n]"
    [2020-04-28 14:48:25,605] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "0[\r][\n]"
    [2020-04-28 14:48:25,605] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
    [2020-04-28 14:48:28,341] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "HTTP/1.1 200 OK[\r][\n]"
    [2020-04-28 14:48:28,341] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Date: Tue, 28 Apr 2020 09:18:20 GMT[\r][\n]"
    [2020-04-28 14:48:28,341] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Strict-Transport-Security: max-age=31536002; includeSubDomains[\r][\n]"
    [2020-04-28 14:48:28,342] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJv
    NEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hp
    kp-report/00D550000000fgkm";[\r][\n]"
    [2020-04-28 14:48:28,342] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Expect-CT: max-age=86400, report-uri="https://a.forcesslreports.com/Expect-CT-report/00D550000000fgkm"[\
    r][\n]"
    [2020-04-28 14:48:28,342] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "X-Content-Type-Options: nosniff[\r][\n]"
    [2020-04-28 14:48:28,343] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "X-XSS-Protection: 1; mode=block[\r][\n]"
    [2020-04-28 14:48:28,343] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "X-Robots-Tag: none[\r][\n]"
    [2020-04-28 14:48:28,343] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private[\r][\n]"
    [2020-04-28 14:48:28,344] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Set-Cookie: BrowserId=M-JoJIkxEeqAhF-kj0dI8Q; domain=.salesforce.com; path=/; expires=Wed, 28-Apr-2021 0
    9:18:20 GMT; Max-Age=31536000[\r][\n]"
    [2020-04-28 14:48:28,344] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Content-Type: application/json;charset=UTF-8[\r][\n]"
    [2020-04-28 14:48:28,344] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Vary: Accept-Encoding[\r][\n]"
    [2020-04-28 14:48:28,345] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "Transfer-Encoding: chunked[\r][\n]"
    [2020-04-28 14:48:28,345] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "[\r][\n]"
    [2020-04-28 14:48:28,345] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "223[\r][\n]"
    [2020-04-28 14:48:28,346] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> ""{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9foAAB\",
    \"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtgEAB\"},\"Company\":\"N/A\",\"Email\":\
    "[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Jaxon\",\"LastName\":\"Stevens\",\"Id\":\"00Q5500000AvbtgEAB\
    ",\"MobilePhone\":\"+61 423 927 100\"},\"errorCode\":\"200\",\"appraisalId\":null}""
    [2020-04-28 14:48:29,084] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "[\r][\n]"
    [2020-04-28 14:48:29,084] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "0[\r][\n]"
    [2020-04-28 14:48:29,084] [] DEBUG - wire HTTPS-Sender I/O dispatcher-3 >> "[\r][\n]"
    [2020-04-28 14:48:29,631] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 200 OK[\r][\n]"
    [2020-04-28 14:48:29,632] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Date: Tue, 28 Apr 2020 09:18:26 GMT[\r][\n]"
    [2020-04-28 14:48:29,632] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Strict-Transport-Security: max-age=31536002; includeSubDomains[\r][\n]"
    [2020-04-28 14:48:29,632] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Public-Key-Pins-Report-Only: pin-sha256="9n0izTnSRF+W4W4JTq51avSXkWhQB8duS2bxVLfzXsY="; pin-sha256="5kJv
    NEMw0KjrCAu7eXY5HZdvyCS13BbA0VJG1RSP91w="; pin-sha256="njN4rRG+22dNXAi+yb8e3UMypgzPUPHlv4+foULwl1g="; max-age=86400; includeSubDomains; report-uri="https://a.forcesslreports.com/hp
    kp-report/00D550000000fgkm";[\r][\n]"
    [2020-04-28 14:48:29,633] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Expect-CT: max-age=86400, report-uri="https://a.forcesslreports.com/Expect-CT-report/00D550000000fgkm"[\
    r][\n]"
    [2020-04-28 14:48:29,634] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Content-Type-Options: nosniff[\r][\n]"
    [2020-04-28 14:48:29,634] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-XSS-Protection: 1; mode=block[\r][\n]"
    [2020-04-28 14:48:29,634] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Robots-Tag: none[\r][\n]"
    [2020-04-28 14:48:29,634] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private[\r][\n]"
    [2020-04-28 14:48:29,635] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: BrowserId=N0LRQokxEeqAhF-kj0dI8Q; domain=.salesforce.com; path=/; expires=Wed, 28-Apr-2021 0
    9:18:26 GMT; Max-Age=31536000[\r][\n]"
    [2020-04-28 14:48:29,635] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/json;charset=UTF-8[\r][\n]"
    [2020-04-28 14:48:29,635] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Vary: Accept-Encoding[\r][\n]"
    [2020-04-28 14:48:29,636] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Transfer-Encoding: chunked[\r][\n]"
    [2020-04-28 14:48:29,636] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
    [2020-04-28 14:48:29,636] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "226[\r][\n]"
    [2020-04-28 14:48:29,637] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> ""{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:29\",\"OpportunityId\":\"0065500000Fz9fyAAB\",
    \"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtlEAB\"},\"Company\":\"N/A\",\"Email\":\
    "[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Brendan\",\"LastName\":\"Dunleavy\",\"Id\":\"00Q5500000AvbtlE
    AB\",\"MobilePhone\":\"+61 449 819 834\"},\"errorCode\":\"200\",\"appraisalId\":null}"[\r][\n]"
    [2020-04-28 14:48:29,637] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "0[\r][\n]"
    [2020-04-28 14:48:29,638] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
    [2020-04-28 14:48:29,651] []  INFO - LogMediator ======OUTSEQUENCE======= = CALLED

连线记录-2:脚本相关的连线记录

[2020-04-28 14:48:29,653] []  INFO - LogMediator To: , WSAction: , SOAPAction: , MessageID: urn:uuid:14c06142-fccf-4a80-ba38-b8f040c992de, Direction: response, Envelope: <?xml vers
        ion='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><jsonObject xmlns="http://ws.apache.org/ns/synapse"><jsonValue
         xmlns="">"{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9ftAAB\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"
        type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB\"},\"Company\":\"N/A\",\"Email\":\"[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSou
        rce\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"LastName\":\"Ross\",\"Id\":\"00Q5500000AvbtbEAB\",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",
        \"appraisalId\":null}"</jsonValue><jsonValue xmlns="">"{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9foAAB\",\"message\":\"Insert/U
        pdate success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtgEAB\"},\"Company\":\"N/A\",\"Email\":\"jaxonstevens18@gmail.
        com\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Jaxon\",\"LastName\":\"Stevens\",\"Id\":\"00Q5500000AvbtgEAB\",\"MobilePhone\":\"+6
        1 423 927 100\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue><jsonValue xmlns="">"{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:29\",\"OpportunityId\":\"0065
        500000Fz9fyAAB\",\"message\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtlEAB\"},\"Company\":\"
        N/A\",\"Email\":\"[email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV i-Motor - Get a Quote\",\"FirstName\":\"Brendan\",\"LastName\":\"Dunleavy\",\"Id\":\
        "00Q5500000AvbtlEAB\",\"MobilePhone\":\"+61 449 819 834\"},\"errorCode\":\"200\",\"appraisalId\":null}"</jsonValue></jsonObject></soapenv:Body></soapenv:Envelope>
        [2020-04-28 14:48:29,658] []  INFO - LogMediator ====each payload==== = "{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9ftAAB\",\"me
        ssage\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB\"},\"Company\":\"N/A\",\"Email\":\"ste
        [email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"LastName\":\"Ross\",\"Id\":\"00Q5500000AvbtbEAB
        \",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",\"appraisalId\":null}"
        [2020-04-28 14:48:29,665] []  INFO - CommonScriptMessageContext script payload::::{"transactionId":null,"timestamp":"2020-04-28 19:18:24","OpportunityId":"0065500000Fz9ftAAB","mess
        age":"Insert/Update success","Lead":{"attributes":{"type":"Lead","url":"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB"},"Company":"N/A","Email":"[email protected]","L
        ead_Type__c":"Internet","LeadSource":"LDV Facebook - Book a Test Drive","FirstName":"Stephen","LastName":"Ross","Id":"00Q5500000AvbtbEAB","MobilePhone":"+61 414 404 774"},"errorCod
        e":"200","appraisalId":null}
        [2020-04-28 14:48:29,666] []  INFO - LogMediator ====each payload==== = "{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9ftAAB\",\"me
        ssage\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB\"},\"Company\":\"N/A\",\"Email\":\"ste
        [email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"LastName\":\"Ross\",\"Id\":\"00Q5500000AvbtbEAB
        \",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",\"appraisalId\":null}"
        [2020-04-28 14:48:29,671] []  INFO - CommonScriptMessageContext script payload::::{"transactionId":null,"timestamp":"2020-04-28 19:18:24","OpportunityId":"0065500000Fz9ftAAB","mess
        age":"Insert/Update success","Lead":{"attributes":{"type":"Lead","url":"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB"},"Company":"N/A","Email":"[email protected]","L
        ead_Type__c":"Internet","LeadSource":"LDV Facebook - Book a Test Drive","FirstName":"Stephen","LastName":"Ross","Id":"00Q5500000AvbtbEAB","MobilePhone":"+61 414 404 774"},"errorCod
        e":"200","appraisalId":null}
        [2020-04-28 14:48:29,672] []  INFO - LogMediator ====each payload==== = "{\"transactionId\":null,\"timestamp\":\"2020-04-28 19:18:24\",\"OpportunityId\":\"0065500000Fz9ftAAB\",\"me
        ssage\":\"Insert/Update success\",\"Lead\":{\"attributes\":{\"type\":\"Lead\",\"url\":\"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB\"},\"Company\":\"N/A\",\"Email\":\"ste
        [email protected]\",\"Lead_Type__c\":\"Internet\",\"LeadSource\":\"LDV Facebook - Book a Test Drive\",\"FirstName\":\"Stephen\",\"LastName\":\"Ross\",\"Id\":\"00Q5500000AvbtbEAB
        \",\"MobilePhone\":\"+61 414 404 774\"},\"errorCode\":\"200\",\"appraisalId\":null}"
        [2020-04-28 14:48:29,678] []  INFO - CommonScriptMessageContext script payload::::{"transactionId":null,"timestamp":"2020-04-28 19:18:24","OpportunityId":"0065500000Fz9ftAAB","mess
        age":"Insert/Update success","Lead":{"attributes":{"type":"Lead","url":"/services/data/v48.0/sobjects/Lead/00Q5500000AvbtbEAB"},"Company":"N/A","Email":"[email protected]","L
        ead_Type__c":"Internet","LeadSource":"LDV Facebook - Book a Test Drive","FirstName":"Stephen","LastName":"Ross","Id":"00Q5500000AvbtbEAB","MobilePhone":"+61 414 404 774"},"errorCod
        e":"200","appraisalId":null}
javascript wso2 wso2esb rhino wso2ei
1个回答
0
投票

根据For-Each和Iterate中介器的功能,整个消息将根据您提供的表达分为几部分。因此,对于每个介体,仅内部处理了jsonValue的一部分。

要删除斜线,您可以直接调用脚本中间人。或者,如果您想为每个调解人删除每个对象下的斜线,那么您当前的代码是正确的,但不会立即处理所有消息。

或者,您可以使用聚合介体将所有拆分消息合并为一个有效负载。

编辑#1:

尝试使用此代码,它会删除斜线。

<foreach id="foreach_id" expression="//jsonValue">
   <sequence>
      <property name="jsonString" expression="json-eval($)" scope="default" type="STRING"/>
      <script language="js">var log = mc.getServiceLog();
       var payload = mc.getProperty('jsonString').toString();
       log.info("script payload::::" + payload); 
       var payloadRemoveSlash = payload.replace('\\', '').replace('"{','{').replace('}"','}'); 
       mc.setProperty('payloadRemoveSlash',payloadRemoveSlash.toString());
       </script>
       <log>
         <property name=":: Body Inside payloadRemoveSlash::" expression="$ctx:payloadRemoveSlash"/>
      </log>
   </sequence>
</foreach>

现在,您可以使用扩展介体将此属性转换为主体,然后调用所需的端点。提供的是,您使用Iterate Mediator而不是For Each Mediator。

© www.soinside.com 2019 - 2024. All rights reserved.