Walkthrough for consuming web service from ruby?

Hey All,

I've got a .net web service that I need to drive from ruby. I
*thought* I had it working, using the soap/wsdlDriver library, but it
looks like I was wrong. :frowning:

Is there a beginner-level HOWTO or other such hand-holdy document that
I could read to start getting my bearings w/this stuff? I've had bad
luck trying to find one on ruby-doc and google. The little bit in
pickaxe 2 is not working for me.

Thanks!

-Roy

I'm gearing up to consume a webservice in a Rails app myself. I've been
looking at soap4r and found a decent tutorial on it. Maybe it will
help...

http://raa.ruby-lang.org/project/soap4r

Hi,

rpardee@gmail.com wrote:

I've got a .net web service that I need to drive from ruby. I
*thought* I had it working, using the soap/wsdlDriver library, but it
looks like I was wrong. :frowning:

Is there a beginner-level HOWTO or other such hand-holdy document that
I could read to start getting my bearings w/this stuff? I've had bad
luck trying to find one on ruby-doc and google. The little bit in
pickaxe 2 is not working for me.

Sorry for that. Soap4r distribution package at
http://dev.ctor.org/download/ contains bunch of examples and no document
by me. English is the most complex and headachy language for me. (Do
not ask me what languages I'm comparing with.)

Posting about "pickaxe 2 is not working" to soap4r ML (or here) may
solve the problem.

Regards,
// NaHi

Ooh, that does look helpful--I'll give it a go.

Thanks!

-Roy

Hee-hee--"I feel your pain" as they say.

Here's my script:

require "soap/wsdlDriver"
WSGUID = "39AC29C5-68BB-4678-BD6D-6486FA277544"
WSDL_URL =
"http://ctrhs-devnet/pardre1/MailException/ExceptionMailer.asmx?wsdl"

proxobj = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
proxobj.sendGeneralMessageRPC("pardee.r@ghc.org", "subject: sent from
script", "this was sent from a ruby script.", WSGUID)

Which, when submitted results in:

c:/ruby/lib/ruby/1.8/wsdl/operation.rb:67:in `outputparts': undefined
method `find_message' for nil:NilClass (NoMethodError)
  from c:/ruby/lib/ruby/1.8/wsdl/soap/methodDefCreator.rb:72:in
`collect_documentparameter'
  from c:/ruby/lib/ruby/1.8/soap/wsdlDriver.rb:132:in `create_param_def'
  from c:/ruby/lib/ruby/1.8/soap/wsdlDriver.rb:101:in `add_operation'
  from c:/ruby/lib/ruby/1.8/soap/wsdlDriver.rb:96:in `each'
  from c:/ruby/lib/ruby/1.8/xsd/namedelements.rb:57:in `each'
  from c:/ruby/lib/ruby/1.8/xsd/namedelements.rb:57:in `each'
  from c:/ruby/lib/ruby/1.8/soap/wsdlDriver.rb:96:in `add_operation'
  from c:/ruby/lib/ruby/1.8/soap/wsdlDriver.rb:40:in `create_rpc_driver'
  from C:/Documents and Settings/pardre1/Desktop/DelMe.rb:5

Here is the WSDL (hopefully this will come through--I'm posting via
google groups)

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:s1="http://microsoft.com/wsdl/types/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tns="http://tempuri.org/MailException/ExceptionMailer"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://tempuri.org/MailException/ExceptionMailer"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
  <wsdl:types>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://tempuri.org/MailException/ExceptionMailer">
      <s:import namespace="http://microsoft.com/wsdl/types/" />
      <s:element name="Send">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="User"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="Machine"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1"
name="ExceptionString" type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="recipient"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="AppName"
type="s:string" />
          </s:sequence>
        </s:complexType>
      </s:element>
      <s:element name="SendGeneralMessage">
        <s:complexType>
          <s:sequence>
            <s:element minOccurs="0" maxOccurs="1" name="recipients"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="subject"
type="s:string" />
            <s:element minOccurs="0" maxOccurs="1" name="body"
type="s:string" />
            <s:element minOccurs="1" maxOccurs="1" name="key"
type="s1:guid" />
          </s:sequence>
        </s:complexType>
      </s:element>
    </s:schema>
    <s:schema elementFormDefault="qualified"
targetNamespace="http://microsoft.com/wsdl/types/">
      <s:simpleType name="guid">
        <s:restriction base="s:string">
          <s:pattern
value="[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
/>
        </s:restriction>
      </s:simpleType>
    </s:schema>
  </wsdl:types>
  <wsdl:message name="SendSoapIn">
    <wsdl:part name="parameters" element="tns:Send" />
  </wsdl:message>
  <wsdl:message name="SendGeneralMessageSoapIn">
    <wsdl:part name="parameters" element="tns:SendGeneralMessage" />
  </wsdl:message>
  <wsdl:message name="SendGeneralMessageRPCSoapIn">
    <wsdl:part name="recipients" type="s:string" />
    <wsdl:part name="subject" type="s:string" />
    <wsdl:part name="body" type="s:string" />
    <wsdl:part name="key" type="s:string" />
  </wsdl:message>
  <wsdl:message name="SendGeneralMessageRPCSoapOut" />
  <wsdl:portType name="ExceptionMailerSoap">
    <wsdl:operation name="Send">
      <wsdl:input message="tns:SendSoapIn" />
    </wsdl:operation>
    <wsdl:operation name="SendGeneralMessage">
      <wsdl:input message="tns:SendGeneralMessageSoapIn" />
    </wsdl:operation>
    <wsdl:operation name="SendGeneralMessageRPC">
      <wsdl:input message="tns:SendGeneralMessageRPCSoapIn" />
      <wsdl:output message="tns:SendGeneralMessageRPCSoapOut" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="ExceptionMailerSoap"
type="tns:ExceptionMailerSoap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="document" />
    <wsdl:operation name="Send">
      <soap:operation
soapAction="http://tempuri.org/MailException/ExceptionMailer/Send"
style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
    </wsdl:operation>
    <wsdl:operation name="SendGeneralMessage">
      <soap:operation
soapAction="http://tempuri.org/MailException/ExceptionMailer/SendGeneralMessage"
style="document" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
    </wsdl:operation>
    <wsdl:operation name="SendGeneralMessageRPC">
      <soap:operation
soapAction="http://tempuri.org/MailException/ExceptionMailer/SendGeneralMessageRPC"
style="rpc" />
      <wsdl:input>
        <soap:body use="encoded"
namespace="http://tempuri.org/MailException/ExceptionMailer"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="encoded"
namespace="http://tempuri.org/MailException/ExceptionMailer"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="ExceptionMailer">
    <documentation xmlns="http://schemas.xmlsoap.org/wsdl/" />
    <wsdl:port name="ExceptionMailerSoap"
binding="tns:ExceptionMailerSoap">
      <soap:address
location="http://ctrhs-devnet/pardre1/MailException/ExceptionMailer.asmx"
/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

Hi,

rpardee@gmail.com wrote:

Hee-hee--"I feel your pain" as they say.

Here's my script:

Thanks. Hmm. No operation definition in Send method... It should
intend to one-way operation.

Unfortunately current soap4r does not support one-way operation. Do you
know what HTTP response is expected for "Send" operation you are
calling? HTTP-200(OK) response with empty body? Or SOAP Envelope with
empty SOAPBody?

You seem to use ASP.NET at server side so I think you can browse sample
request wiredump and sample response wiredump by accessing
ExceptionMailer.asmx ...

Regards,
// NaHi

Okay--I've resolved this by taking the one-way attributes off the 2
webmethods that had them. Looks like it's working fine now. Thanks
for the pointer!

Cheers,

-Roy