使用 Ruby 的 Savon SOAP 库,如何将常见的“env:mustUnderstand”属性添加到 SOAP 请求标头中的 Security 标记?默认情况下,它不包含在标签中。
这是我当前的测试代码:
require 'rubygems'
require 'savon'
client = Savon::Client.new do
wsdl.document = File.expand_path("../service_wsdl.xml", __FILE__)
end
client.wsse.credentials "[removed]", "[removed]"
p client.request :get_meta_data # Server returns 500 error (presumably due to improper header)
这是正在发送的 XML(不包括 mustUnderstand 属性):
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="urn:wsdl.ws.[removed].com/v1.1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ins0="urn:messages.ws.[removed].com/v1.1" xmlns:ins1="urn:objects.ws.[removed].com/v1.1" xmlns:ins2="urn:base.ws.[removed].com/v1.1" xmlns:ins3="urn:nullfields.ws.[removed].com/v1.1" xmlns:ins4="urn:generic.ws.[removed].com/v1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ins5="urn:metadata.ws.[removed].com/v1.1" xmlns:ins6="urn:faults.ws.[removed].com/v1.1" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="UsernameToken-1">
<wsse:Username>[removed]</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">[removed]</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</env:Header>
<env:Body>
<GetMetaData/>
</env:Body>
</env:Envelope>