Closed PiotrNestor closed 12 years ago
just tested the collect_namespaces
method and for me it's returning the expected result:
{ "soap" => "http://schemas.xmlsoap.org/wsdl/soap/",
"tns" => "http://v1_0.ws.auth.order.example.com/",
"wsdl" => "http://schemas.xmlsoap.org/wsdl/" }
can you provide me with that wsdl, your ruby version and the version of nokogiri you're running?
/usr/bin/ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
/usr/bin/gem list --local
*** LOCAL GEMS ***
akami (1.0.0)
builder (3.0.0)
facade (1.0.5)
ffi (1.0.11)
gyoku (0.4.4)
httpi (0.9.7)
json (1.7.1)
json_pure (1.7.1)
mediainfo (0.7.2)
multipart-post (1.1.5)
mysql (2.8.1)
net-scp (1.0.4)
net-ssh (2.3.0)
nokogiri (1.5.2)
nori (1.1.0)
quick_magick (0.8.0)
rack (1.4.1)
rake (0.9.2.2)
rubyforge (2.0.4)
rubyzip (0.9.8)
savon (0.9.9)
sys-uname (0.9.0)
test-unit (2.4.8)
wasabi (2.1.0)
xml-simple (1.1.1)
The Soap Service wsdl file: https://gist.github.com/2658561
installed ruby 1.9.2-p0 and tested with both wasabi (2.1.0):
require "wasabi"
doc = Wasabi.document File.read("vapix.wsdl")
doc.parser.namespaces
# { "wsdl" => "http://schemas.xmlsoap.org/wsdl/", ...
# "wstop" => "http://docs.oasis-open.org/wsn/t-1" }
and nokogiri (1.5.2):
require "nokogiri"
doc = Nokogiri.XML File.read("vapix.wsdl")
doc.collect_namespaces
# { "xmlns:wsdl" => "http://schemas.xmlsoap.org/wsdl/", ...
# "xmlns:wstop" => "http://docs.oasis-open.org/wsn/t-1" }
can you run the code snippets above and verify that nokogiri's collect_namespaces
method is the problem?
I get the following results with wasabi 2.1.0
require "wasabi"
doc = Wasabi.document File.read("vapix.wsdl")
doc.parser.namespaces
{"h"=>"t"}
and with nokogiri 1.5.2
require "nokogiri"
doc = Nokogiri.XML File.read("vapix.wsdl")
doc.collect_namespaces
{"xmlns:wsdl"=>"http://schemas.xmlsoap.org/wsdl/",
"xmlns:aa"=>"http://www.axis.com/vapix/ws/action1",
"xmlns:wsnt"=>"http://docs.oasis-open.org/wsn/b-2",
"xmlns:soap"=>"http://schemas.xmlsoap.org/wsdl/soap12/",
"xmlns"=>"http://www.w3.org/1999/xhtml",
"xmlns:xs"=>"http://www.w3.org/2001/XMLSchema",
"xmlns:wstop"=>"http://docs.oasis-open.org/wsn/t-1"}
don't know why it would return { "h" => "t" }
, but it looks like collect_namespaces
isn't the problem, right?
at least it returns the namespaces as expected instead of returning:
{ 0 => ["xmlns:wsdl", "http://schemas.xmlsoap.org/wsdl/"] }
For what it's worth, with Nokogiri 1.5.2 I am in line with @rubiii in getting a result from collect_namespaces
like:
{"xmlns:wsdl"=>"http://schemas.xmlsoap.org/wsdl/", "xmlns:aa"=>"http://www.axis.com/vapix/ws/action1", "xmlns:wsnt"=>"http://docs.oasis-open.org/wsn/b-2", "xmlns:soap"=>"http://schemas.xmlsoap.org/wsdl/soap12/", "xmlns"=>"http://www.w3.org/1999/xhtml", "xmlns:xs"=>"http://www.w3.org/2001/XMLSchema", "xmlns:wstop"=>"http://docs.oasis-open.org/wsn/t-1"}
... which is also the format the Nokogiri documentation details at http://nokogiri.org/Nokogiri/XML/Document.html#method-i-collect_namespaces.
@PiotrNestor , are you sure you're using pristine, unmodified versions of Nokogiri and Wasabi to get your results? The {"h"=>"t"}
result looks a lot like what you'd get running your suggested inject
on the documented response from collect_namespaces
:
# Ruby 1.9.2, Nokogiri 1.5.2:
require 'nokogiri'
doc = Nokogiri.XML File.read("vapix.wsdl")
doc.collect_namespaces
# => {"xmlns:wsdl"=>"http://schemas.xmlsoap.org/wsdl/", "xmlns:aa"=>"http://www.axis.com/vapix/ws/action1", "xmlns:wsnt"=>"http://docs.oasis-open.org/wsn/b-2", "xmlns:soap"=>"http://schemas.xmlsoap.org/wsdl/soap12/", "xmlns"=>"http://www.w3.org/1999/xhtml", "xmlns:xs"=>"http://www.w3.org/2001/XMLSchema", "xmlns:wstop"=>"http://docs.oasis-open.org/wsn/t-1"}
_.inject({}) { |result, (key, value)| result.merge(value[0].gsub(/xmlns:/, "") => value[1]) }
# => {"h"=>"t"}
closing this as the problem doesn't seem to be related to wasabi.
ruby 1.9.3 wasabi 2.1.0
I'm getting the following problem when parsing SOAP:
The problem is that 'collect_namespaces' returns a hash like:
The 'inject' should be then like:
Is this a known problem with wasabi parse_namespaces? Is the fix acceptable?
Regards Piotr