Вопрос

In Savon 1, I could use the soap.input to add xmlns like following:

soap_client = Savon.client("http://pathtowsdl.com/a.svc?wsdl")

response = soap_client.request "AnAction" do
  http.headers["soapAction"] = "AnAction"
  soap.input = ["AnAction", {"xmlns" => "http://apathtosomething.com"}]
  soap.body = {
    "SomeAttribute" => "SomeValue"
  }
end

In Savon 2, I can do client.call(:authenticate, message_tag: :authenticationRequest) but how to add the xmlns to the authenticationRequest tag?

Это было полезно?

Решение

You have to add the attribute to the call, eg.

client.call('CreateRequest', :attributes => { 'xmlns' => 'xyz' })

Другие советы

#!/usr/bin/env ruby

require 'savon'

soap_client = Savon.client( endpoint: 'http://example.com',
                            namespace: 'http://v1.example.com')
soap_client.call(:authenticate, 
                 message_tag: :authenticationRequest, 
                 :attributes => { "xmlns" => "http://apathtosomething.com" })

outputs

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:wsdl="http://v1.example.com"
              xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <wsdl:authenticationRequest xmlns="http://apathtosomething.com">
    </wsdl:authenticationRequest>
  </env:Body>
</env:Envelope>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top