How to stop Savon from adding prefixes to soap.body

后端 未结 1 1610
生来不讨喜
生来不讨喜 2021-01-06 12:56

This is how I am creating a a client:

@client = Savon::Client.new do
  wsdl.document = my_document
  wsdl.endpoint = my_endpoint
end

and th

1条回答
  •  耶瑟儿~
    2021-01-06 13:46

    This looks like it might be a bug in savon 0.9.6. Try updating your client creating code like this:

    @client = Savon::Client.new do
      wsdl.document = my_document
      wsdl.endpoint = my_endpoint
      wsdl.element_form_default = :unqualified
    end
    

    Edit: updating answer with solution if someone else comes across this issue

    It turns out if you provide a wsdl.document savon will prefix your elements. You're better off not using the wsdl document and just defining the namespaces you need like this:

    @client = Savon::Client.new do
      wsdl.endpoint = "http://..."
      wsdl.namespace = "http://..." # target namespace
    end
    
    @response = @client.request :namespace_prefix, :soap_action do
      soap.element_form_default = :unqualified
      soap.namespaces["xmlns:ns1"] = "http://..."
      soap.namespaces["xmlns:ns2"] = "http://..."
    
      soap.body =  {:application_id => my_application_id }
    end
    

    0 讨论(0)
提交回复
热议问题