NC56 XML 报文校验出错一例

好好的上线了、下午开完会告诉我有个凭证没法传入 NC 了。

请求报文如下:

<?xml version="1.0" encoding='UTF-8'?>
<ufinterface roottag="voucher" billtype="gl" replace="Y" receiver="10108" sender="FSSC" isexchange="Y" filename="FSPG-2023112300012.xml" proc="add" operation="req"><voucher id="9c5f0852ffffd8c6ccfa9a23b1b2b7ae3b37"><voucher_body><entry><auxiliary_accounting><item name ="收支项目">运输费</item><item name ="部门档案">销售部</item></auxiliary_accounting><exchange_rate2>1.0000000000</exchange_rate2><account_code>6601</account_code><currency>CNY</currency><abstract>支付出口运费(xxx)</abstract><entry_id>1</entry_id><primary_debit_amount>1.00</primary_debit_amount><natural_debit_currency>1.00</natural_debit_currency></entry><entry><auxiliary_accounting><item name ="内部账户辅助核算">10108</item></auxiliary_accounting><primary_credit_amount>7810.00</primary_credit_amount><exchange_rate2>1.0000000000</exchange_rate2><account_code>1010</account_code><currency>CNY</currency><abstract>FOB运费</abstract><entry_id>2</entry_id><natural_credit_currency>1.00</natural_credit_currency></entry></voucher_body><voucher_head><voucher_affair_no>FSPG-2023112300012</voucher_affair_no><pk_boeno>FSPG-RCFY2311220109</pk_boeno><checkeddate/><checker/><attachment_number>6</attachment_number><fiscal_year>2023</fiscal_year><voucherkind>0</voucherkind><voucher_making_system>总账</voucher_making_system><voucher_type>银行付款凭证</voucher_type><prepareddate>2023-11-28</prepareddate><memo1>报销xx有限公司运输费出口印度FOB费,客户INDU, 订单FSPG20230711-1&2</memo1><company>10108</company><enter>FSSC</enter><accounting_period>11</accounting_period><signflag>N</signflag></voucher_head></voucher></ufinterface>

不管是直接在 NC 对应组织下的 “交换平台 - 手动加载界面” 加载报文,还是使用 postman 请求 NC ERP 生产环境、都返回同样的错误:

从输入流转换document出错:请检验文档格式。\n

思来想去,如果 xml 报文的标签尖括号是成对出现的、那么就是报文的内容有问题。直到我看到了 Encoding Special Characters in XML | Baeldung

这篇文章。里面罗列了常见的 xml 特殊字符:

Entity Character Represented
&amp;     Ampersand – &
&apos;     Apostrophe – ‘
&gt; Greater-than sign – >
&lt; Less-than sign – <
&quot;     Quotation mark – “

于是把目光投向了那个可疑的 “&” 符号。

为了稳妥起见,找了 NC 测试环境的外部交换接口;架起 postman 发送了生产环境的报文。

去掉 “&” 之前的报文反馈如下:

<?xml version="1.0" encoding='UTF-8'?>
   <ufinterface billtype="" filename="" isexchange="Y" proc="" receiver="" replace="Y" roottag="sendresult" sender="" successful="N">
      <sendresult>
         <billpk></billpk>
         <bdocid></bdocid>
         <filename></filename>
         <resultcode>
            -31003
         </resultcode>
         <resultdescription>
            从输入流转换document出错:请检验文档格式。\n
         </resultdescription>
         <content></content>
</sendresult>
</ufinterface>

去掉 “&” 之后的报文反馈如下:

<?xml version="1.0" encoding='UTF-8'?>
   <ufinterface billtype="gl" filename="FSPG-2023112300012.xml" isexchange="Y" proc="add" receiver="10108" replace="Y" roottag="sendresult" sender="FSSC" successful="N">
      <sendresult>
         <billpk></billpk>
         <bdocid></bdocid>
         <filename></filename>
         <resultcode>
            -31114
         </resultcode>
         <resultdescription>
            交换环境初始化异常:无法获得数据源,账套:fspg
         </resultdescription>
         <content></content>
</sendresult>
</ufinterface>

问题不大,至少能传进去了(滑稽)

只能感叹对方系统的单纯、知道是发送 xml 报文还不对标签里的内容做转码、服了。。:)

(完)

相关推荐

  1. NC56 XML 校验出错

    2023-12-05 20:14:06       40 阅读
  2. 每日练 - PIM协议类型辨析

    2023-12-05 20:14:06       7 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-05 20:14:06       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-05 20:14:06       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-05 20:14:06       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-05 20:14:06       20 阅读

热门阅读

  1. WeakMap

    WeakMap

    2023-12-05 20:14:06      42 阅读
  2. 机器学习(四十九):Mean-Shift 聚类

    2023-12-05 20:14:06       39 阅读
  3. js轮播图示例代码

    2023-12-05 20:14:06       38 阅读
  4. 【软件测试学习】—软件质量需求(四)

    2023-12-05 20:14:06       33 阅读
  5. 第十四周课堂笔记

    2023-12-05 20:14:06       39 阅读
  6. 企业微信HOOK开发接口调用,发送语音消息

    2023-12-05 20:14:06       53 阅读
  7. 《微信小程序开发从入门到实战》学习四十一

    2023-12-05 20:14:06       29 阅读
  8. golang函数的返回值

    2023-12-05 20:14:06       39 阅读