savon

SAVON setting envelope namespace in the envelope


i'm trying to add a namespace in my envelop for xmlns:api= and set the url as example:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="http://api.notes.xyz.com/">

not having much success in finding examples. Is this possible?


Solution

  • What I have done in the past was the following (I always preferred to go without WSDL). Perhaps you can use it:

    #!/usr/bin/env ruby
    
    require 'savon'
    
    additional_ns = {
     'xmlns:api' => "http://api.notes.xyz.com/"
    }
    
    client = Savon.client(
        :endpoint => "http://www.example.com/endpoint",
        :namespace => "xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/",
        :namespaces => additional_ns,
        :log => true,
        :log_level => :debug,
        :pretty_print_xml => true,
        :ssl_verify_mode => :none
    )
    
    client.call(....)