我现在感到很茫然,我正在尝试添加选项以将包发送到UPS接入点,文档告诉我需要为UAP(013)和ADL添加通知对象(012)
当我阅读文档时,通知对象最多允许3次,通常在xml中看起来像:
<ShipmentServiceOptions>
<Notification>
<NotificationCode>012</NotificationCode>
some other values ( here..)
</Notification>
<Notification>
<NotificationCode>013</NotificationCode>
some other values ( here..)
</Notification>
</ShipmentServiceOptions>
但是因为我正在使用JSON,所以我创建了一个对象数组:
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '012'];
$Shipment['ShipmentServiceOptions']['Notification'][] = ['NotificationCode' => '013'];
当我对json解码这个完整的数组时,它看起来像:
{
"Notification": [{
"NotificationCode": "013",
"EmailMessage": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "fromemail@test.com",
"FromName": "From Email"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}, {
"NotificationCode": "012",
"EmailMessage": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "From Email",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}]
}
这是一个有效的json对象,但由于某种原因,我不断收到错误:
ADL通知代码(012)和通知数据(电子邮件或电话号码)需要在接入点位置发货时保留。
当我翻转数组值时,我会得到错误:
UPS接入点交付需要UAP托运人通知代码(013)和通知数据(电子邮件或电话号码)。
这让我觉得从数组中只读取了1个值,并且阅读文档会让我相信它需要多个Notification键,但我真的不知道如何在json中添加多个Notification键,将无效json对象..任何帮助将不胜感激
修改
当我将JSON对象转换为如下所示:
"ShipmentServiceOptions": [{
"Notification": {
"NotificationCode": "013",
"EmailMessage": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "fromemail",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}
}, {
"Notification": {
"NotificationCode": "012",
"EmailMessage": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "fromemail",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}
}],
它给了我这个错误:
ADL通知代码(012)和通知数据(电子邮件或电话号码)需要在接入点位置发货时保留。
交换项目不会改变错误
答案 0 :(得分:1)
我知道这将是一件简单的事情,如果需要一个多小时来解决,你知道这很简单; - )
我将xml文档与Web服务文档交换,在xml中调用添加通知电子邮件数据的节点:
/ ShipmentConfirmRequest /装运/ ShipmentServiceOptions /通知/ EMailMessage /
在JSON文档中,调用了保存邮件数据的同一节点:
/ ShipmentConfirmRequest /装运/ ShipmentServiceOptions /通知/电子邮件/
为了完整性,这是通知对象的正确json部分:
{
"Notification": [{
"NotificationCode": "013",
"EMail": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "fromemail",
"FromName": "fromemail"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}, {
"NotificationCode": "012",
"EMail": {
"EMailAddress": "info@tom-it.nl",
"UndeliverableEMailAddr": "info@tom-it.nl",
"FromEMailAddress ": "fromname",
"FromName": "From Name"
},
"Locale": {
"Language": "ENG",
"Dialect": "US"
}
}]
}