WSO2有效负载工厂附加带有JSON请求的附加字段

时间:2015-07-31 07:09:30

标签: json wso2 wso2esb payload

我正在WSO2 ESB中创建一个JSON有效负载。但是最近我注意到在点击端点时,它在消息体的开头和结尾添加了一些额外的字段。因此,JSON结构正在改变,结果无法生成实际结果。从普通日志中看不到额外字段,但如果启用http wire log,则可以注意到这些字段。我正在粘贴下面的代码以及电线日志。

    <payloadFactory media-type="json">
                        <format>
                                        {
        "ExtReference": "$8",
        "MemberSubType":{
            "MemberSubTypeId":"20",
            "Name":"DD"},
        "Region": "",        
        "PersonalDetails": {
            "FirstName": "$9",
            "LastName": "sample",
            "MiddleName": "",
            "DateOfBirth": "",
            "GenderType": "",
            "SalutationType":"",
            "MemberStatus":""
        },
        "Address": [{
            "AddressLine1": "$1",
            "AddressLine2": "$2",
            "HouseName": "",
            "HouseNumber": "",
            "Street": "",
            "Locality": "",
            "City": "$3",
            "County": "",
            "Zip": "$15",
            "CountryId": "NZ",
            "PostBox": "",
            "PostBoxNumber": ""
        }],
        "ContactDetails": [{
            "Email": "$5",
            "Phone": "$10",
            "MobilePhone": "$7",
            "Fax": "$6",
            "ContactDetailsType": ""
        }],
        "ExtensionData": [{
            "PropertyName":"", 
            "PropertyValue":""
            }]
}
                                    </format>
                        <args>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:addr1/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:addr2/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:city/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:country/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:email/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:fax/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:mobile/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:nSInternalID/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:name/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:phone/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:salesRep/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:state/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:territory/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:url/text()"/>
                           <arg evaluator="xml"
                                expression="//cus:addParentCustToJADERequest/cus:parentCustData/cus:zip/text()"/>
                        </args>
                     </payloadFactory>
                     <property name="messageType"
                               value="application/json"
                               scope="axis2"
                               type="STRING"/>
                     <log separator=", ****JSON_Request****">
                        <property name="toJSON" expression="json-eval($.)"/>
                     </log>
                     <call>
                        <endpoint>
                           <http method="post" uri-template="http://localhost:8281/scholasticapi/member"/>
                           <property name="Authorization"
                                     value="78ca6121-763c-41c6-8dfe-d73e761b9989;https://uat.snipp.ie/scholasticapi/member;Fri Jul 24 2015 15:03:02 GMT+0530 (India Standard Time);idiuOEsgiVQU2cJj2p2nawCEHGtyN1cIWzpHP+NlJm4="
                                     scope="transport"/>
                           <property name="Content-Type" value="application/json" scope="transport"/>
                        </endpoint>
                     </call>

当它到达端点时,我记录了启用线路的请求。

[2015-07-30 19:15:23,854] DEBUG - wire << "[\r][\n]"
[2015-07-30 19:15:23,855] DEBUG - wire << "44d[\r][\n]"
[2015-07-30 19:15:23,855] DEBUG - wire << "{[\n]"
[2015-07-30 19:15:23,856] DEBUG - wire << "        "ExtReference": "4545",[\n]"
[2015-07-30 19:15:23,856] DEBUG - wire << "        "MemberSubType":{[\n]"
[2015-07-30 19:15:23,856] DEBUG - wire << "[0x9][0x9][0x9]"MemberSubTypeId":"20",[\n]"
[2015-07-30 19:15:23,861] DEBUG - wire << "[0x9][0x9][0x9]"Name":"DD"},[\n]"
[2015-07-30 19:15:23,861] DEBUG - wire << "        "Region": "",        [\n]"
[2015-07-30 19:15:23,862] DEBUG - wire << "        "PersonalDetails": {[\n]"
[2015-07-30 19:15:23,862] DEBUG - wire << "            "FirstName": "arisan",[\n]"
[2015-07-30 19:15:23,862] DEBUG - wire << "            "LastName": "sample",[\n]"
[2015-07-30 19:15:23,863] DEBUG - wire << "            "MiddleName": "",[\n]"
[2015-07-30 19:15:23,863] DEBUG - wire << "            "DateOfBirth": "",[\n]"
[2015-07-30 19:15:23,863] DEBUG - wire << "            "GenderType": "",[\n]"
[2015-07-30 19:15:23,863] DEBUG - wire << "            "SalutationType":"",[\n]"
[2015-07-30 19:15:23,864] DEBUG - wire << "            "MemberStatus":""[\n]"
[2015-07-30 19:15:23,864] DEBUG - wire << "        },[\n]"
[2015-07-30 19:15:23,864] DEBUG - wire << "        "Address": [{[\n]"
[2015-07-30 19:15:23,865] DEBUG - wire << "            "AddressLine1": "vfhd",[\n]"
[2015-07-30 19:15:23,865] DEBUG - wire << "            "AddressLine2": "jdfvbgkjfds",[\n]"
[2015-07-30 19:15:23,865] DEBUG - wire << "            "HouseName": "",[\n]"
[2015-07-30 19:15:23,865] DEBUG - wire << "            "HouseNumber": "",[\n]"
[2015-07-30 19:15:23,866] DEBUG - wire << "            "Street": "",[\n]"
[2015-07-30 19:15:23,866] DEBUG - wire << "            "Locality": "",[\n]"
[2015-07-30 19:15:23,866] DEBUG - wire << "            "City": "kolkata",[\n]"
[2015-07-30 19:15:23,866] DEBUG - wire << "            "County": "",[\n]"
[2015-07-30 19:15:23,867] DEBUG - wire << "            "Zip": "43543",[\n]"
[2015-07-30 19:15:23,867] DEBUG - wire << "            "CountryId": "NZ",[\n]"
[2015-07-30 19:15:23,867] DEBUG - wire << "            "PostBox": "",[\n]"
[2015-07-30 19:15:23,867] DEBUG - wire << "            "PostBoxNumber": ""[\n]"
[2015-07-30 19:15:23,868] DEBUG - wire << "        }],[\n]"
[2015-07-30 19:15:23,868] DEBUG - wire << "        "ContactDetails": [{[\n]"
[2015-07-30 19:15:23,868] DEBUG - wire << "            "Email": "sdjk@hs.com",[\n]"
[2015-07-30 19:15:23,868] DEBUG - wire << "            "Phone": "378654839674",[\n]"
[2015-07-30 19:15:23,869] DEBUG - wire << "            "MobilePhone": "87425343287",[\n]"
[2015-07-30 19:15:23,869] DEBUG - wire << "            "Fax": "345435",[\n]"
[2015-07-30 19:15:23,869] DEBUG - wire << "            "ContactDetailsType": ""[\n]"
[2015-07-30 19:15:23,869] DEBUG - wire << "        }],[\n]"
[2015-07-30 19:15:23,870] DEBUG - wire << "        "ExtensionData": [{[\n]"
[2015-07-30 19:15:23,870] DEBUG - wire << "[0x9][0x9][0x9]"PropertyName":"", [\n]"
[2015-07-30 19:15:23,870] DEBUG - wire << "[0x9][0x9][0x9]"PropertyValue":""[\n]"
[2015-07-30 19:15:23,870] DEBUG - wire << "[0x9][0x9][0x9]}][\n]"
[2015-07-30 19:15:23,871] DEBUG - wire << "}[\r][\n]"
[2015-07-30 19:15:23,871] DEBUG - wire << "0[\r][\n]"
[2015-07-30 19:15:23,871] DEBUG - wire << "[\r][\n]"

在日志的第二行中显示值 44d ,在第二行中显示附加的值,该值未在有效负载中的任何位置提供。我已从系统所有者确认,对于这两个垃圾值,只有请求失败。请建议一种方法来获得这两个领域的芦苇。提前致谢。

2 个答案:

答案 0 :(得分:1)

最后这个零与有效负载返回客户端的方式有关,这就是“分块”传输。

(参见:https://en.wikipedia.org/wiki/Chunked_transfer_encoding

简而言之,44d只是这个“块”的一部分字节数。最后一个“0”意味着没有更多的块。

答案 1 :(得分:1)

您可以在将请求发送到后端服务器之前使用:<property name="DISABLE_CHUNKING" value="true" scope="axis2"/>。 这样可以正常工作......