2

Using the Savon SOAP library for Ruby, how can I add the common "env:mustUnderstand" attribute to the Security tag in the header of a SOAP request? By default, it isn't included in the tag.

Here is my current test code:

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)

Here is the XML that is being sent (which doesn't include the mustUnderstand attribute):

<?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>
YWCA Hello
  • 2,997
  • 4
  • 29
  • 40

0 Answers0