ruby-on-rails - Savon 不使用参数填充 XML
问题描述
系统:
ruby 2.7.3p183(2021-04-05 修订版 6847ee089d)[x86_64-darwin20]
萨翁2.12.1
我的客户端设置如下所示
def client
@client ||= Savon.client do
log true
wsdl BASE_URL
pretty_print_xml true
ssl_verify_mode :none
end
end
当我查看日志以验证 Savon 生成的 XML 时,我注意到缺少一些参数。在这种情况下,它是customerID
要求:
client.call(:authenticate, message: { customerID: 123456, passphrase: 'qwertyasdfg' })
日志:
I, [2021-07-06T13:06:29.621011 #39758] INFO -- : SOAP request: *filtered*
I, [2021-07-06T13:06:29.621067 #39758] INFO -- : SOAPAction: "*filtered*", Content-Type: text/xml;charset=UTF-8, Content-Length: 569
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="*filtered*" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<authenticate>
<customerID xsi:type="xsd:nonNegativeInteger"/>
<passphrase xsi:type="xsd:normalizedString">qwertyasdfg</passphrase>
<sandbox xsi:type="xsd:boolean"/>
<locale xsi:type="tns:Locale"/>
<demo xsi:type="xsd:boolean"/>
</authenticate>
</env:Body>
</env:Envelope>
D, [2021-07-06T13:06:29.621467 #39758] DEBUG -- : HTTPI /none POST request to *filtered* (httpclient)
I, [2021-07-06T13:06:29.994037 #39758] INFO -- : SOAP response (status 400)
D, [2021-07-06T13:06:29.994316 #39758] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Failed to authenticate.</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
您可以在此处看到customerID参数未填充值123456。我的设置中是否缺少任何内容?这不是第一个案例。它也发生在其他请求上,所以我必须单独构建 XML 并使用带有原始 XML 的 API 进行操作
解决方案
推荐阅读
- scala - 计算增量类型不匹配错误的无形示例
- f# - 什么是错误“类型实例化涉及 byref 类型。” 什么是 F# 中的解决方法
- java - 在指定页面打开 PDF 在 Java 中与平台无关
- c++ - 拖动时QGraphicsPolygonItem不更新QPolygonF坐标
- assembly - 运行代码时出现错误 MIPS “spim: (parser) syntax error”
- javascript - 如何围绕原点部分旋转一条线?(做一个简笔画波浪)
- bootstrap-4 - Bootstrap 4.4.1 无论我尝试什么,select、text 和 textarea 元素的大小都不会像我需要的那样。有没有人见过这个?
- python - Python Numpy 其中体素是重点?
- matlab - 使用 fread() 从 MATLAB 读取二进制文件数据
- api - 反应本机登录api jwt auth basic