本文主要是介绍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 |
---|---|
& | Ampersand – & |
' | Apostrophe – ‘ |
> | Greater-than sign – > |
< | Less-than sign – < |
" | 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 报文还不对标签里的内容做转码、服了。。:)
(完)
这篇关于NC56 XML 报文校验出错一例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!