# Help with SOAP

**URL:** <https://rubytalk.org/t/help-with-soap/19624>\
**Category:** ruby-talk\
**Created:** [19 July 2005 16:13 UTC](https://rubytalk.org/t/help-with-soap/19624 "2005-07-19T16:13:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ben\_Myles](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Ben\_Myles](https://rubytalk.org/u/Ben_Myles)\
**Post date:** [19 July 2005 16:13 UTC](https://rubytalk.org/t/help-with-soap/19624/1 "2005-07-19T16:13:20Z")

</div>

Hi,

I'm trying to write some code to connect to a SOAP webservice. I only  
need to call one method: SendMessage (see  
[http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage)).

I've been reading PickAxe but it's pretty thin on this stuff. I've got  
the outline of my code done, but am stuck on what arguments to send  
the method call.

result = soap.SendMessage(...)

I realise I need to send the arguments along, but how do I send  
complex datatypes (in the definition URL above you will see there are  
destinations containing recipients etc.). Also, do I need to specify  
every parameter or are some optional? Is it possible to query the web  
service for this information in Ruby?

Any help would be \*greatly\* appreciated.

Thanks in advance,  
Ben

---

<div class="post-metadata">

**Author:** ![NAKAMURA\_Hiroshi4](https://avatars.discourse-cdn.com/v4/letter/n/3ab097/32.png) [@NAKAMURA\_Hiroshi4](https://rubytalk.org/u/NAKAMURA_Hiroshi4)\
**Post date:** [20 July 2005 10:39 UTC](https://rubytalk.org/t/help-with-soap/19624/2 "2005-07-20T10:39:32Z")

</div>

Hi,

Ben Myles wrote:

> I'm trying to write some code to connect to a SOAP webservice. I only  
> need to call one method: SendMessage (see  
> [http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage\](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage%5C)).
> 
> I've been reading PickAxe but it's pretty thin on this stuff. I've got  
> the outline of my code done, but am stuck on what arguments to send  
> the method call.
> 
> result = soap.SendMessage(...)
> 
> I realise I need to send the arguments along, but how do I send  
> complex datatypes (in the definition URL above you will see there are  
> destinations containing recipients etc.). Also, do I need to specify  
> every parameter or are some optional? Is it possible to query the web  
> service for this information in Ruby?

You should use WSDL file located at  
[http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL)

At first, generate class definition from the WSDL as follows.

% wsdl2ruby.rb --wsdl  
'[http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39);  
- --type client --force  
I, [2005-07-20T14:40:25.503516 #32113] INFO -- app: Creating class  
definition.  
W, [2005-07-20T14:40:25.504452 #32113] WARN -- app: File 'default.rb'  
exists but overrides it.  
F, [2005-07-20T14:40:25.570157 #32113] FATAL -- app: Detected an  
exception. Stopping ... undefined method `name' for nil:NilClass  
(NoMethodError)

Oops. I found the bug and fixed it at subversion repository. Please  
obtain the latest soap4r source from its subversion repository, or  
download the latest snapshot tarball from [http://dev.ctor.org/download/](http://dev.ctor.org/download/)

With the latest soap4r source, wsdl2ruby.rb should run fine and the  
following script should work.

&nbsp;&nbsp;#!/usr/bin/env ruby  
&nbsp;&nbsp;require 'defaultDriver.rb'  
&nbsp;&nbsp;obj = FaxProcessorSoap.new  
&nbsp;&nbsp;parameters = SendMessage.new(FaxMessage.new(...), 'NaHi', 'passwd')  
&nbsp;&nbsp;puts obj.sendMessage(parameters)

class FaxMessage is very big. Good luck with you and soap4r...

Regards,  
// NaHi

---

<div class="post-metadata">

**Author:** ![Ben\_Myles](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Ben\_Myles](https://rubytalk.org/u/Ben_Myles)\
**Post date:** [20 July 2005 14:59 UTC](https://rubytalk.org/t/help-with-soap/19624/3 "2005-07-20T14:59:36Z")

</div>

Thanks so much! That's what I call community support - trying it out now 🙂

Ben

> **···**
>
> On 7/20/05, NAKAMURA, Hiroshi \<nakahiro@sarion.co.jp\> wrote:
> 
> > -----BEGIN PGP SIGNED MESSAGE-----  
> > Hash: SHA1
> > 
> > Hi,
> > 
> > Ben Myles wrote:  
> > \> I'm trying to write some code to connect to a SOAP webservice. I only  
> > \> need to call one method: SendMessage (see  
> > \> [http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage\](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?op=SendMessage%5C)).  
> > \>  
> > \> I've been reading PickAxe but it's pretty thin on this stuff. I've got  
> > \> the outline of my code done, but am stuck on what arguments to send  
> > \> the method call.  
> > \>  
> > \> result = soap.SendMessage(...)  
> > \>  
> > \> I realise I need to send the arguments along, but how do I send  
> > \> complex datatypes (in the definition URL above you will see there are  
> > \> destinations containing recipients etc.). Also, do I need to specify  
> > \> every parameter or are some optional? Is it possible to query the web  
> > \> service for this information in Ruby?
> > 
> > You should use WSDL file located at  
> > [http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL)
> > 
> > At first, generate class definition from the WSDL as follows.
> > 
> > % wsdl2ruby.rb --wsdl  
> > '[http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39);  
> > - --type client --force  
> > I, [2005-07-20T14:40:25.503516 #32113] INFO -- app: Creating class  
> > definition.  
> > W, [2005-07-20T14:40:25.504452 #32113] WARN -- app: File 'default.rb'  
> > exists but overrides it.  
> > F, [2005-07-20T14:40:25.570157 #32113] FATAL -- app: Detected an  
> > exception. Stopping ... undefined method `name' for nil:NilClass  
> > (NoMethodError)
> > 
> > Oops. I found the bug and fixed it at subversion repository. Please  
> > obtain the latest soap4r source from its subversion repository, or  
> > download the latest snapshot tarball from [http://dev.ctor.org/download/](http://dev.ctor.org/download/)
> > 
> > With the latest soap4r source, wsdl2ruby.rb should run fine and the  
> > following script should work.
> > 
> > &nbsp;&nbsp;#!/usr/bin/env ruby  
> > &nbsp;&nbsp;require 'defaultDriver.rb'  
> > &nbsp;&nbsp;obj = FaxProcessorSoap.new  
> > &nbsp;&nbsp;parameters = SendMessage.new(FaxMessage.new(...), 'NaHi', 'passwd')  
> > &nbsp;&nbsp;puts obj.sendMessage(parameters)
> > 
> > class FaxMessage is very big. Good luck with you and soap4r...
> > 
> > Regards,  
> > // NaHi  
> > -----BEGIN PGP SIGNATURE-----  
> > Version: GnuPG v1.4.1 (Cygwin)
> > 
> > iD8DBQFC3inhf6b33ts2dPkRAjBPAJ0QBOTDFI/qUfKAawjFl4jP/lsL3ACgjoxH  
> > NaxqRhq2Dr5O95rnuOYUYm0=  
> > =UlxR  
> > -----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Ben\_Myles](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Ben\_Myles](https://rubytalk.org/u/Ben_Myles)\
**Post date:** [21 July 2005 13:21 UTC](https://rubytalk.org/t/help-with-soap/19624/4 "2005-07-21T13:21:23Z")

</div>

Hi,

After following your instructions I managed to use wsdl2ruby to  
generate the files fine. However, when I try to interface with the web  
service, or even just run 'ruby FaxProcessorClient.rb' I get the  
following error:

#\<SOAP::Mapping::Object:0x102c0e0\>: Failed schema validation (SOAP::FaultError)

Any ideas why this might happen? I don't think it's Ruby specific -  
but if you could help at all by pointing me in the right direction I'd  
be very grateful.

Regards,  
Ben Myles

...

> At first, generate class definition from the WSDL as follows.
> 
> % wsdl2ruby.rb --wsdl  
> '[http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39](http://webservices.xpedite.com.au/xpeditemessaging/faxreach/1-0-0/faxreach.asmx?WSDL&#39);  
> - --type client --force

...

> **···**
>
> On 7/20/05, NAKAMURA, Hiroshi \<nakahiro@sarion.co.jp\> wrote:
> 
> > With the latest soap4r source, wsdl2ruby.rb should run fine and the  
> > following script should work.
> > 
> > &nbsp;&nbsp;#!/usr/bin/env ruby  
> > &nbsp;&nbsp;require 'defaultDriver.rb'  
> > &nbsp;&nbsp;obj = FaxProcessorSoap.new  
> > &nbsp;&nbsp;parameters = SendMessage.new(FaxMessage.new(...), 'NaHi', 'passwd')  
> > &nbsp;&nbsp;puts obj.sendMessage(parameters)
> > 
> > class FaxMessage is very big. Good luck with you and soap4r...

---

<div class="post-metadata">

**Author:** ![NAKAMURA\_Hiroshi4](https://avatars.discourse-cdn.com/v4/letter/n/3ab097/32.png) [@NAKAMURA\_Hiroshi4](https://rubytalk.org/u/NAKAMURA_Hiroshi4)\
**Post date:** [21 July 2005 13:51 UTC](https://rubytalk.org/t/help-with-soap/19624/5 "2005-07-21T13:51:07Z")

</div>

Hi,

Ben Myles wrote:

> After following your instructions I managed to use wsdl2ruby to  
> generate the files fine. However, when I try to interface with the web  
> service, or even just run 'ruby FaxProcessorClient.rb' I get the  
> following error:
> 
> #\<SOAP::Mapping::Object:0x102c0e0\>: Failed schema validation (SOAP::FaultError)

Hmm. Some parameter could be wrongly encoded by soap4r. Can I see  
entire error message with the following script?

&nbsp;&nbsp;obj = FaxProcessorSoap.new  
&nbsp;&nbsp;obj.wiredump\_dev = STDOUT # add this line  
&nbsp;&nbsp;obj.sendMessage(...)

Please send me the result directly if it contains internal information.

Regards,  
// NaHi
