问题描述
系统:
ruby 2.7.3p183(2021-04-05 修订版 6847ee089d)[x86_64-darwin20]
savon 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 进行操作
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)