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