Обработка полезных данных внутри посредника скриптов в WSO2 EI / ESB - PullRequest
0 голосов
/ 28 апреля 2020

У меня полезная нагрузка, как показано ниже. Мне нужно получить всю полезную нагрузку внутри посредника сценариев и выполнить операцию удаления sla sh для этой полезной нагрузки . Я не могу получить полную полезную нагрузку, получает только один элемент 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\":\"steveross01@bigpond.com\",\"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\":\"jaxonstevens18@gmail.com\",\"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>

Журналы проводов - 1:

[2020-04-28 14:48:25,594] []  INFO - LogMediator LogText = Salesforce Request Uniqueidentifier:17132e6366d3d561,**, ======SF RequestPayload====== = {"getLead":{"Company":"N/A","Ema
    il":"dunleavy2010@hotmail.com","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":"dunleavy2010@hotmail.com","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\":\
    "jaxonstevens18@gmail.com\",\"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\":\
    "dunleavy2010@hotmail.com\",\"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\":\"steveross01@bigpond.com\",\"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\":\"dunleavy2010@hotmail.com\",\"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
        veross01@bigpond.com\",\"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":"steveross01@bigpond.com","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
        veross01@bigpond.com\",\"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":"steveross01@bigpond.com","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
        veross01@bigpond.com\",\"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":"steveross01@bigpond.com","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}

1 Ответ

0 голосов
/ 28 апреля 2020

В соответствии с функциональностью посредников 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>

Теперь вы можете преобразовать это свойство как тело с помощью посредника enrich и затем вызвать конечная точка, которую вы хотите. При условии, что вы используете Итеративный медиатор вместо Для каждого медиатора.

...