Help with SOAP

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).

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

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\).

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

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'
- --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/

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

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

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

Regards,
// NaHi

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

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\).
>
> 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

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;
- --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/

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

  #!/usr/bin/env ruby
  require 'defaultDriver.rb'
  obj = FaxProcessorSoap.new
  parameters = SendMessage.new(FaxMessage.new(...), 'NaHi', 'passwd')
  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-----

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;
- --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.

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

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

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?

  obj = FaxProcessorSoap.new
  obj.wiredump_dev = STDOUT # add this line
  obj.sendMessage(...)

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

Regards,
// NaHi