unwire / handsoap

Handsoap is a library for creating SOAP clients in Ruby
http://github.com/unwire/handsoap
225 stars 58 forks source link

Does not parse namespaces containing quotes #14

Closed vadimt closed 14 years ago

vadimt commented 14 years ago

The following response throws a 'The response is not a valid SOAP envelope' error due to the single quotes in xmlns:ns1="'daily'_type_quota"

<?xml version="1.0" encoding="UTF-8"?>

SOAP-ENV:Headerns1:remaining_quota23992/ns1:remaining_quotans1:quota_used_so_far8/ns1:quota_used_so_farns1:command_groupAccountManagement/ns1:command_groupns1:quota_typedaily/ns1:quota_type/SOAP-ENV:HeaderSOAP-ENV:Bodyns2:addResponse335511/ns2:addResponse/SOAP-ENV:Body/SOAP-ENV:Envelope
troelskn commented 14 years ago

I'm curious - What's the use case or this? Do you actually have an application with a namespace that contains quotes?

I'll look into the issue, but likely the problem happens at the xml-parser level. Off the top of my head, I'm actually unsure if the above is valid xml.

vadimt commented 14 years ago

This is actually xml that is coming back from an external application API I am integrating with. I wasn't sure if it was valid either, but http://www.w3schools.com/Xml/xml_attributes.asp says that it's ok.

zenchild commented 14 years ago

I cannot replicate this issue in any of the XML parsers. What ruby version and XML parser are you using? I tested both Ruby 1.8.7 and 1.9.2 using this spec file:

http://gist.github.com/559345

vadimt commented 14 years ago

Thanks for looking into this

Ruby 1.8.7 patchlevel 174 Nokogiri 1.4.3.1 Handsoap 1.1.7

The error occurred when running tests using VCR with webmock, changing the mock to remove the single quotes did not throw the error.

zenchild commented 14 years ago

I replicated the error somewhat and traced it back to libxml2. You can try using xmllint which comes with libxml2 to see it throw an error on the namespace with quotes. I tried parsing it with REXML and that worked a bit better. Try and set Handsoap.xml_query_driver = :rexml and see if that works better for you.

vadimt commented 14 years ago

Right on, thank you.