0
如何使用Savon将编码属性添加到body标签?Savon:将编码添加到body标签
一些背景: 我想用savon连接到一个SOAP资源。我可以获取WSDL文件并浏览这些方法。
@client = Savon::Client.new("http://some.domain.com/v2messaging/service?WSDL")
当我尝试使用的登录方法
response = @client.request :service, :login do
soap.body = {
"String_1" => "username",
"String_2" => "password"
}
end
我得到这个错误:
故障/错误:响应= @ client.request:服务:登录做萨翁: :SOAP :: Fault:(env:Client)在处理请求时捕获到异常:意外的编码风格:expected = http://schemas.xmlsoap.org/soap/encoding/,实际
身体标记的区别。这里是预期的XML(通过SOAPUI应用程序中找到):
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:service="etapestryAPI/service">
<env:header/>
<env:body>
<service:login env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<String_1>username</String_1>
<String_2>password</String_2>
</service:login>
</env:body>
</env:Envelope>
萨翁发送:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:service="etapestryAPI/service" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://java.sun.com/jax-rpc-ri/internal" xmlns:ins1="etapestryAPI/service">
<env:Body>
<service:login>
<String_1>username</String_1>
<String_2>password</String_2>
</service:login>
</env:Body>
</env:Envelope>
有这之间的一些差异,但错误返回已与ENV做:encodingStyle属性在env:login标签上。如何添加此属性?