Rahul
Rahul

Reputation: 73

Using WSDL With 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?

Upvotes: 3

Views: 3985

Answers (2)

Morton Fox
Morton Fox

Reputation: 186

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.

Upvotes: 1

Swanand
Swanand

Reputation: 12426

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

Upvotes: 2

Related Questions