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

(完)

相关推荐
arbalest108018 小时前
xml文件学习
xml
开开心心_Every1 天前
定时管理进程:防止沉迷电脑的软件推荐
xml·java·运维·服务器·网络·数据库·excel
水哥ansys1 天前
ANSYS Workbench ACT二次开发XML语法介绍
xml·二次开发·水哥ansys
程序猿零零漆2 天前
Spring之旅 - 记录学习 Spring 框架的过程和经验(二)基于Xml方式Bean的配置
xml·spring
开开心心_Every3 天前
无广告干扰:简单好用文字LOGO设计工具
xml·java·网络·数据库·华为od·华为云·excel
武子康3 天前
Java-210 Spring AMQP 整合 RabbitMQ:JavaConfig 注解配置、RabbitTemplate 发送/同步接收与坑位速查
xml·java·spring·消息队列·rabbitmq·java-rabbitmq·mq
jiayong233 天前
`.flattened-pom.xml` 深度解析
xml
小李飞飞砖3 天前
RemoteViews的layout无法设置xml类型的Drawable,会报错
xml
武子康3 天前
Java-209 Spring AMQP 整合 RabbitMQ 实战:XML 配置直连交换机、RabbitAdmin 自动声明与收发闭环
xml·java·spring·rabbitmq·java-rabbitmq·java-activemq
利刃大大6 天前
【Mybatis】Mybatis入门 && 基础操作 && XML配置文件开发 && 多表查询 && 注入问题 && 数据库连接池
xml·数据库·mybatis