Search code examples
rubysoapsavon

Savon with Builder::Xmlmarkup is not escaping the smaller/greater signs


the below code, generates the following xml.

as you may see the the smaller/greater signs are not showing as '<' or '>' and the server is not happy about this.

any hint/suggestions are appreciated. Thanks!

<env:Body>
<find>
    <filter>&lt;and&gt;&lt;equal name="foo" value="1"/&gt;&lt;/and&gt;</filter>
</find>
</env:Body>


def find 
    s_xml = Builder::XmlMarkup.new
    s_xml.and do
        s_xml.equal(:name => "foo", :value => 1)
    end

    body = {
        :filter => [s_xml.target!],
    }
    _send_query :find, body 
end

def _send_query method, body, server=@primary_server
    client = Savon::client do
        wsdl.endpoint = server
        wsdl.namespace = server
    end

    client.config.pretty_print_xml = true

    response = client.request method do 
        soap.body = body
    end

    return response.to_hash
end

Solution

  • the answer is put an exclamation mark, (not ampersand @rubiii) like: :filter! => [s_xml.target!]

    << after the filter!!