# Consuming a SOAP Service in Ruby

**URL:** <https://www.ruby-forum.com/t/consuming-a-soap-service-in-ruby/191144>\
**Category:** Ruby\
**Created:** [July 6, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/consuming-a-soap-service-in-ruby/191144 "2010-07-06T13:39:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://www.ruby-forum.com/u/saeed)\
**Post date:** [July 6, 2010, 1:39pm UTC](https://www.ruby-forum.com/t/consuming-a-soap-service-in-ruby/191144/1 "2010-07-06T13:39:33Z")

</div>

Hi,

I am trying to consume a SOAP service. I don’t know a lot about this  
area but from what I have read, I have come up with the following code  
so far;

require ‘soap/wsdlDriver’

wsdl=“[http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx](http://realtime.nationalrail.co.uk/ldbws/wsdl.aspx)”

driverFactory = SOAP::WSDLDriverFactory.new(wsdl)

p ‘\>\>\>\>\>\>\>\>here’  
service = driverFactory.create\_rpc\_driver

board=service.GetDepartureBoard(4, ‘ALN’, ‘’, ‘’)

However I am getting the following error;  
“ignored element: {[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)}maxLength of  
WSDL::XMLSchema::SimpleRestriction  
ignored element: {[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)}maxLength of  
WSDL::XMLSchema::SimpleRestriction  
ignored attr: {}default  
/usr/lib/ruby/1.8/wsdl/import.rb:44:in `parse_attr': undefined method `targetnamespace=’ for #WSDL::XMLSchema::Schema:0x..fdb72b8a6  
(NoMethodError)”

I’m assuming the error is related to the namespace?

Would sincerely appreciate it if someone could point me in the right  
direction.

Saeed

---

<div class="post-metadata">

**Author:** ![saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://www.ruby-forum.com/u/saeed)\
**Post date:** [July 6, 2010, 7:59pm UTC](https://www.ruby-forum.com/t/consuming-a-soap-service-in-ruby/191144/2 "2010-07-06T19:59:28Z")

</div>

I’ve had lots and lots of problems with soap4r in the past and would  
most  
certainly not recommend it. Try Savon instead:

> **[GitHub - rubiii/savon: Moved to savonrb/savon](https://github.com/rubiii/savon)**
>
> Moved to savonrb/savon. Contribute to rubiii/savon development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![saeed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e8c25b/32.png) [@saeed](https://www.ruby-forum.com/u/saeed)\
**Post date:** [July 7, 2010, 4:41pm UTC](https://www.ruby-forum.com/t/consuming-a-soap-service-in-ruby/191144/3 "2010-07-07T16:41:46Z")

</div>

The wsdl you presented is fairly short, I’ve found the easiest way to  
implement small SOAP enpoints in ruby is to do this:

- Use Java or .NET Tools to create bindings out of the WSDL
- Make one or two sample calls.
- sniff the xml generated by those calls and use it to create  
templates for ruby.

Unfortunately, SOAP is one of the most convoluted protocols the earth  
has ever seen. The above may sound a bit TOO pragmatic, but you’ll  
save yourself a world of hurt.

-tim
