NC56 XML 报文校验出错一例

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

请求报文如下:

XML 复制代码
<?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 生产环境、都返回同样的错误:

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

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

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

| Entity | Character Represented |

&amp; Ampersand -- &
' Apostrophe -- '
&gt; Greater-than sign -- >
&lt; Less-than sign -- <
&quot; Quotation mark -- "

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

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

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

XML 复制代码
<?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 复制代码
<?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 报文还不对标签里的内容做转码、服了。。:)

(完)

相关推荐
开始了码13 小时前
XML文件介绍和QT相关操作
xml·qt
Andy工程师19 小时前
logback-spring.xml优先级更高
xml·spring·logback
小江村儿的文杰21 小时前
UE4在MacOS上将Commit.gitdeps.xml设为Git LFS文件的潜在弊端
xml·ue4
humstone1 天前
基于xml 和sql 实现自定义报表查询
xml·数据库·sql
就叫飞六吧2 天前
考古spring.xml注册bean无法扫描目录问题
xml·java·spring
Star abuse2 天前
XML转YOLO格式数据集教程
xml·人工智能·yolo
gAlAxy...3 天前
MyBatis 核心配置文件 SqlMapConfig.xml 全解析
xml·mybatis
编程修仙4 天前
第十一篇 Spring事务
xml·java·数据库·spring
金士顿4 天前
Ethercat耦合器添加的IO导出xml 初始化IO参数
android·xml·java
烤麻辣烫5 天前
黑马程序员苍穹外卖后端概览
xml·java·数据库·spring·intellij-idea