node.js - 错误:节点中的肥皂客户端的 XML 格式无效(联邦快递)
问题描述
我在节点中使用肥皂向 Fedex Web 服务发出请求以上传文件。要上传的文档可以是转换为 base64 的有效文件类型(比方说,多页的 pdf)。如果此 PDF 必须只有一个页面,则流程完全可以正常工作。但是,如果 PDF 是多页的,我会从 Fedex 收到以下错误:
"Invalid XML","detail":"Error: Unexpected close tag\nLine: 0\nColumn: 127\nChar: >".
为了调试这个,我提取了发送到联邦快递的 xml 请求:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="http://fedex.com/ws/uploaddocument/v11"><soap:Body><ns:UploadDocumentsRequest xmlns:ns="http://fedex.com/ws/uploaddocument/v11" xmlns="http://fedex.com/ws/uploaddocument/v11"><ns:WebAuthenticationDetail><ns:UserCredential><ns:Key>*******</ns:Key><ns:Password>******</ns:Password></ns:UserCredential></ns:WebAuthenticationDetail><ns:ClientDetail><ns:AccountNumber>*****</ns:AccountNumber><ns:MeterNumber>*****</ns:MeterNumber></ns:ClientDetail><ns:Version><ns:ServiceId>cdus</ns:ServiceId><ns:Major>11</ns:Major><ns:Intermediate>0</ns:Intermediate><ns:Minor>0</ns:Minor></ns:Version><ns:OriginCountryCode>IN</ns:OriginCountryCode><ns:DestinationCountryCode>CN</ns:DestinationCountryCode><ns:Usage>ELECTRONIC_TRADE_DOCUMENTS</ns:Usage><ns:Documents><ns:CustomerReference></ns:CustomerReference><ns:DocumentType>PRO_FORMA_INVOICE</ns:DocumentType><ns:FileName>1810e200-4467-11e8-b6a8-07a18eeb7b1a.pdf-test.pdf</ns:FileName><ns:DocumentContent>Base64String</ns:DocumentContent></ns:Documents></ns:UploadDocumentsRequest></soap:Body></soap:Envelope>
请求中的变量“Base64String”可以假定为正在发送的文件。关于这个错误是什么以及这有什么意义的任何帮助?让我知道是否可能需要任何其他信息
解决方案
如果您使用 xml2js 来转换您的请求,这很可能是这种情况,请确保您升级到版本 0.4.2。首先删除它,然后安装该版本:
npm uninstall --save xml2js
npm install --save xml2js@0.4.2
此问题已在此版本中处理
推荐阅读
- python - 为什么我的代码永远运行,我已经很久没有运行代码了。然而,没有输出。我走了很长的路吗?下面的所有1个代码
- vba - 如何插入将根据 Environ("USERNAME") 选择的构建块?
- c# - 在 IIS 中部署时出现错误:未找到视图“索引”或其主视图或没有视图引擎支持搜索的位置
- python - 服务器信息命令 discord.py
- qt - 渐变忽略父圆形
- flutter - 如何在 Flutter 中显示选定文本的 iOS 查找模式?
- mysql - 内部连接查询中的问题不是唯一的别名表
- swift - 当内容更改时,如何让 contentView 调整大小?
- javascript - 如何在不使用引导程序且仅使用纯 CSS 的情况下进行多选?
- django - 如何将模板表中显示的信息导出到excel Django