我正在尝试发送此JSON有效内容:
{
"ExtReference": "12345678",
"MemberSubType":{
"MemberSubTypeId":"20",
"Name":"DD"},
"Region": "",
"PersonalDetails": {
"FirstName": "arisan",
"LastName": "sample",
"MiddleName": "",
"DateOfBirth": "",
"GenderType": "",
"SalutationType":"",
"MemberStatus":""
},
"Address": [{
"AddressLine1": "vfhd",
"AddressLine2": "jdfvbgkjfds",
"HouseName": "",
"HouseNumber": "",
"Street": "",
"Locality": "",
"City": "kolkata",
"County": "",
"Zip": "43543",
"CountryId": "NZ",
"PostBox": "",
"PostBoxNumber": ""
}],
"ContactDetails": [{
"Email": "sdjk@hs.com",
"Phone": "378654839674",
"MobilePhone": "87425343287",
"Fax": "345435",
"ContactDetailsType": ""
}],
"ExtensionData": [{
"PropertyName":"",
"PropertyValue":""
}]
}
在ESB日志中正确记录了有效负载。但是在顺序上,我根本没有得到理想的结果。我想以下面的格式回复:
{"Success":true,"Message":"null","Data":1888304}
相反,我得到了:
{"Success":false,"Message":"The resource submitted contains no data: please check the information is correct and try again","Data":null}
我已经从外部休息客户端验证了记录的JSON有效负载,它给了我正确的响应。
以下是我用来发送JSON有效负载的代理代码:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="SNIPCustomerTest"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full" separator=", **Incoming_Request**"/>
<header xmlns:cus="http://www.example.org/customerWSO2/"
name="cus:passport"
scope="default"
action="remove"/>
<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"/>
<log separator=", ****JSON_Request****">
<property name="toJSON" expression="json-eval($.)"/>
</log>
<send>
<endpoint>
<http method="post" uri-template="https://uat.snipp.ie/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="axis2"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="messageType"
value="application/json"
scope="axis2"
type="STRING"/>
<log separator=", **Incoming_Response**" description="Incoming_Response">
<property name="toJSON" expression="json-eval($.)"/>
</log>
<respond/>
<send/>
</outSequence>
<faultSequence>
<log level="full"/>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
name="Code"
expression="//soapenv:Fault/faultcode"
scope="default"
type="STRING"/>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
name="Message"
expression="//soapenv:Fault/faultstring"
scope="default"
type="STRING"/>
<enrich>
<source type="inline" clone="true">
<SoapFault xmlns="">
<Code/>
<Message/>
</SoapFault>
</source>
<target type="body"/>
</enrich>
<enrich>
<source type="property" clone="true" property="Code"/>
<target xpath="//SoapFault/Code"/>
</enrich>
<enrich>
<source type="property" clone="true" property="Message"/>
<target xpath="//SoapFault/Message"/>
</enrich>
<send/>
</faultSequence>
</target>
<publishWSDL key="conf:/myresources/Customer.wsdl"/>
<description/>
</proxy>