Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WSDL With Ruby

Tags:

soap

wsdl

ruby

I'm getting this error:

WSDL::XMLSchema::Parser::UnknownElementError

unknown element: {}HTML
at 'new' 

when I consume webservices using Ruby. Here is the code snippet:

require 'soap/wsdlDriver'

wsdl = url
driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
driver.options["protocol.http.basic_auth"] << [url, user_name, password]

the url points to a well-formed xml.

Any solutions?

like image 790
Rahul Avatar asked Nov 28 '25 15:11

Rahul


2 Answers

Can you share the wsdl file? Maybe that would help us answering it better.
In any case, I'd suggest generating the Driver classes first using wsdl2ruby. And then loding them in your Ruby file (through require). Examples (from the man pages):

# For server side:
$ wsdl2ruby.rb --wsdl myapp.wsdl --type server
# For client side:
$ wsdl2ruby.rb --wsdl myapp.wsdl --type client
like image 120
Swanand Avatar answered Dec 02 '25 03:12

Swanand


If you load the URL in a web browser, does it get redirected to a different location?

In my experience, one reason the error "unknown element: {}HTML" comes up is the WSDL parser is trying to parse the HTML portion of the HTTP redirect and failing to do so. Therefore, you should deal with the redirect yourself (either in code or manually) and give the WSDL driver the final URL.

like image 42
Morton Fox Avatar answered Dec 02 '25 03:12

Morton Fox



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!