如何使用 Savon 将属性添加到标头标签?
我的 SOAP 文档中的标头需要具有如下属性:
<soap:Header>
<eWAYHeader xmlns="https://www.eway.com.au/gateway/managedpayment">
<eWAYCustomerID>string</eWAYCustomerID>
<Username>string</Username>
<Password>string</Password>
</eWAYHeader>
eWAYHeader 需要 xmlns 属性。
我已经尝试过了,
def create_customer(customer, card)
response = @client.request(:create_customer, "xmlns" => "https://www.eway.com.au/gateway/managedpayment") do
soap.header = header
soap.body = create_customer_body(customer, card)
end
end
private
def header
{
"eWAYHeader" => {
:attributes! => { :xmlns => 'http://www.eway.com.au/gateway/managedpayment' },
"eWayCustomerID" => '87654321',
"Username" => '[email protected]',
"Password"=> 'test123'
}
}
end
但是属性!输入被忽略。
Soap.header 只接受哈希作为参数,所以我不能只使用字符串设置它的值。
我如何在 Savon 中实现这一目标?
谢谢,
马丁
The header in my SOAP doc needs to have an attribute like this:
<soap:Header>
<eWAYHeader xmlns="https://www.eway.com.au/gateway/managedpayment">
<eWAYCustomerID>string</eWAYCustomerID>
<Username>string</Username>
<Password>string</Password>
</eWAYHeader>
The eWAYHeader needs an xmlns attribute.
I've tried
def create_customer(customer, card)
response = @client.request(:create_customer, "xmlns" => "https://www.eway.com.au/gateway/managedpayment") do
soap.header = header
soap.body = create_customer_body(customer, card)
end
end
private
def header
{
"eWAYHeader" => {
:attributes! => { :xmlns => 'http://www.eway.com.au/gateway/managedpayment' },
"eWayCustomerID" => '87654321',
"Username" => '[email protected]',
"Password"=> 'test123'
}
}
end
but the attributes! entry is ignored.
soap.header will only accept a Hash as an argument so I can't just set it's value using a string.
How do I achieve this in Savon?
thanks,
Martin
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以通过这样做来实现
You can achieve by doing this