weixin_39816946
2020-12-01 10:04Add wsa headers to requests automatically
Some SOAP endpoints expect the wsa headers 'wsa:Action' and 'wsa:To' to be present in every request. In the request it looks like this. Note that the 'wsa:Action' contains the request name (Echo in this case) so it is different for every request and can not be set globally.
xml
<header xmlns:wsa="http://www.w3.org/2005/08/addressing">
...
<action>http://host/Api/Echo</action>
<to>https://host/Api.svc</to>
...
</header>
In SoapUI, there is a tickbox that makes it automatically add the wsa headers with all the values read from the WSDL. It would be nice to have something similar in Savon2 and enable the headers in the globals. It could look like this:
ruby
Savon.client(default_wsa_headers: true)
Just for reference, this is how the wsa headers can be added to a request in Savon1:
ruby
response = client.request 'Echo' do
soap.version = 2
soap.namespaces["xmlns:wsa"] = "http://www.w3.org/2005/08/addressing"
soap.header = {
"wsa:To" => "https://host/Api.svc",
"wsa:Action" => "http://host/Api/Echo",
}
end
And a workaround in Savon2 looks like this:
ruby
client.globals.soap_header(
"wsa:To" => "https://host/Api.svc",
"wsa:Action" => "http://host/Api/Echo",
)
client.call ...
该提问来源于开源项目:savonrb/savon
- 点赞
- 回答
- 收藏
- 复制链接分享
8条回答
为你推荐
- 用php给自己发电子邮件
- html
- forms
- php
- 4个回答
- 如何在一个字段数组中删除空响应?
- forms
- php
- 2个回答
- PHP和Simplecml_load_string和Xpath来回显特定的值
- xpath
- xml
- namespaces
- php
- 2个回答
- 在PHP中将XML响应转换为数组
- xml
- soap
- php
- 1个回答
- php nusoap服务器无法读取标头安全性
- web-services
- nusoap
- soap
- php
- 1个回答
换一换