【发布时间】:2019-06-21 22:17:59
【问题描述】:
在一个 RoR 应用程序上,我正在处理哪个图书承运人发货,当我尝试使用发送标签请求的 TNT API 进行预订时,我收到以下错误:
Exception: BookingLib::Errors::AwbDocumentFailedException
Error code: awb_xml_failure
Error data:
9200
Issue with validating TNT common systems data
我不知道为什么会这样,这意味着什么。
我的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<labelRequest>
<consignment key="CON1">
<consignmentIdentity>
<consignmentNumber>123456782</consignmentNumber>
<customerReference>Robert's computer</customerReference>
</consignmentIdentity>
<collectionDateTime>2008-06-12T13:00:00</collectionDateTime>
<sender>
<name><%= transform_to_tnt_char_set(tnt_sender.company_name) %></name>
<addressLine1><%= transform_to_tnt_char_set(tnt_sender.address_line1) %></addressLine1>
<addressLine2><%= transform_to_tnt_char_set(tnt_sender.address_line2) %></addressLine2>
<addressLine3><%= transform_to_tnt_char_set(tnt_sender.address_line3) %></addressLine3>
<town><%= transform_to_tnt_char_set(tnt_sender.city) %></town>
<exactMatch>Y</exactMatch>
<province>Warks</province>
<postcode><%= transform_to_tnt_char_set(tnt_sender.zip_code) %></postcode>
<country><%= transform_to_tnt_char_set(tnt_sender.country_code) %></country>
</sender>
<delivery>
<name><%= transform_to_tnt_char_set(tnt_recipient.company_name) %></name>
<addressLine1><%= transform_to_tnt_char_set(tnt_recipient.address_line1) %></addressLine1>
<addressLine2><%= transform_to_tnt_char_set(tnt_recipient.address_line2) %></addressLine2>
<town><%= transform_to_tnt_char_set(tnt_recipient.city) %></town>
<exactMatch>Y</exactMatch>
<province/>
<postcode><%= transform_to_tnt_char_set(tnt_recipient.zip_code) %></postcode>
<country><%= transform_to_tnt_char_set(tnt_recipient.country_code) %></country>
</delivery>
<product>
<lineOfBusiness>2</lineOfBusiness>
<groupId>0</groupId>
<subGroupId>0</subGroupId>
<id>EX</id>
<type>N</type>
<option>PR</option>
</product>
<account>
<accountNumber>100445</accountNumber>
<accountCountry>GB</accountCountry>
</account>
<totalNumberOfPieces>3</totalNumberOfPieces>
<pieceLine>
<identifier>1</identifier>
<goodsDescription>piecelinegoods desc</goodsDescription>
<pieceMeasurements>
<length>1.11</length>
<width>1.11</width>
<height>1.11</height>
<weight>1.11</weight>
</pieceMeasurements>
<pieces>
<sequenceNumbers>1,2</sequenceNumbers>
<pieceReference>keyboard and mouse</pieceReference>
</pieces>
<pieces>
<sequenceNumbers>3</sequenceNumbers>
<pieceReference>computer tower</pieceReference>
</pieces>
</pieceLine>
</consignment>
</labelRequest>
预订调用 API 以获取带有 XML 参数的标签,并且应该显示已准备好打印。但是,我得到了我无法理解的错误 9200。
如果需要更多代码,我愿意请求编辑我的问题。
Rendered XML
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<labelRequest>\n
<consignment key=\"CON1\">\n
<consignmentIdentity>\n
<consignmentNumber>123456782</consignmentNumber>\n
<customerReference>Robert's computer</customerReference>\n
</consignmentIdentity>\n
<collectionDateTime>2008-06-12T13:00:00</collectionDateTime>\n
<sender>\n
<name>HeyHO</name>\n
<addressLine1>Sollerodgade 25,3</addressLine1>\n
<addressLine2></addressLine2>\n
<addressLine3></addressLine3>\n
<town>Kobenhavn N</town>\n
<exactMatch>Y</exactMatch>\n
<province>Warks</province>\n
<postcode>2200</postcode>\n
<country>dk</country>\n
</sender>\n
<delivery>\n
<name>Customer B</name>\n
<addressLine1>Sollerodgade 25,3</addressLine1>\n
<addressLine2></addressLine2>\n
<town>Kobenhavn N</town>\n
<exactMatch>Y</exactMatch>\n
<province/>\n
<postcode>2200</postcode>\n
<country>dk</country>\n
</delivery>\n
<product>\n
<lineOfBusiness>2</lineOfBusiness>\n
<groupId>0</groupId>\n
<subGroupId>0</subGroupId>\n
<id>EX</id>\n
<type>N</type>\n
<option>PR</option>\n
</product>\n
<account>\n
<accountNumber>100445</accountNumber>\n
<accountCountry>GB</accountCountry>\n
</account>\n
<totalNumberOfPieces>3</totalNumberOfPieces>\n
<pieceLine>\n
<identifier>1</identifier>\n
<goodsDescription>piecelinegoods desc</goodsDescription>\n
<pieceMeasurements>\n
<length>1.11</length>\n
<width>1.11</width>\n
<height>1.11</height>\n
<weight>1.11</weight>\n
</pieceMeasurements>\n
<pieces>\n
<sequenceNumbers>1,2</sequenceNumbers>\n
<pieceReference>keyboard and mouse</pieceReference>\n
</pieces>\n
<pieces>\n
<sequenceNumbers>3</sequenceNumbers>\n
<pieceReference>computer tower</pieceReference>\n
</pieces>\n
</pieceLine>\n
</consignment>\n
</labelRequest>"
(byebug) label_request_xml
"
<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n
<labelRequest>\n
<consignment key=\"CON1\">\n
<consignmentIdentity>\n
<consignmentNumber>123456782</consignmentNumber>\n
<customerReference>Robert's computer</customerReference>\n
</consignmentIdentity>\n
<collectionDateTime>2008-06-12T13:00:00</collectionDateTime>\n
<sender>\n
<name>HeyHO</name>\n
<addressLine1>Sollerodgade 25,3</addressLine1>\n
<addressLine2></addressLine2>\n
<addressLine3></addressLine3>\n
<town>Kobenhavn N</town>\n
<exactMatch>Y</exactMatch>\n
<province>Warks</province>\n
<postcode>2200</postcode>\n
<country>dk</country>\n
</sender>\n
<delivery>\n
<name>Customer B</name>\n
<addressLine1>Sollerodgade 25,3</addressLine1>\n
<addressLine2></addressLine2>\n
<town>Kobenhavn N</town>\n
<exactMatch>Y</exactMatch>\n
<province/>\n
<postcode>2200</postcode>\n
<country>dk</country>\n
</delivery>\n
<product>\n
<lineOfBusiness>2</lineOfBusiness>\n
<groupId>0</groupId>\n
<subGroupId>0</subGroupId>\n
<id>EX</id>\n
<type>N</type>\n
<option>PR</option>\n
</product>\n
<account>\n
<accountNumber>100445</accountNumber>\n
<accountCountry>GB</accountCountry>\n
</account>\n
<totalNumberOfPieces>3</totalNumberOfPieces>\n
<pieceLine>\n
<identifier>1</identifier>\n
<goodsDescription>piecelinegoods desc</goodsDescription>\n
<pieceMeasurements>\n
<length>1.11</length>\n
<width>1.11</width>\n
<height>1.11</height>\n
<weight>1.11</weight>\n
</pieceMeasurements>\n
<pieces>\n
<sequenceNumbers>1,2</sequenceNumbers>\n
<pieceReference>keyboard and mouse</pieceReference>\n
</pieces>\n
<pieces>\n
<sequenceNumbers>3</sequenceNumbers>\n
<pieceReference>computer tower</pieceReference>\n
</pieces>\n
</pieceLine>\n
</consignment>\n
</labelRequest>
【问题讨论】:
-
向我们展示呈现的 xml,plz
-
@NeverBe 添加了呈现的 XML
-
我在行尾看到 CR,然后转义。是只有打印出来还是发到服务器的时候?
-
打印我认为当我请求标签时是 XML
-
去掉不需要的字符或者尽量不使用xml模板,只是将数据序列化为xml
标签: ruby-on-rails xml api