Topic: Consuming .NET web service using ruby - actionwebservice

Hi,

Environment: ruby 1.8.6, rails 1.2.3
I am trying to access the .NET web service for sending two parameter and adding those two and return.  So based on this,

I wrote ruby on rails code is,

require 'rubygems'
gem 'mumboe-soap4r'
require 'soap/rpc/driver'

XSD::Charset.encoding = 'UTF8'

wsdlfile = "http://10.1.12.96/satya/service1.asmx?WSDL"
namespace = "http://tempuri.org/"
webmethod = "HelloWorld"
#set the SOAP operation name http://www.gurusonthego.com/ValidateLogin
soapoperation = namespace + webmethod
param1 = "fname"
param2 = "lname"
fname = "senthil"
lname = "raj"

#Initializing the SOAP RPC driver using the WSDL
driver = SOAP::RPC::Driver.new(wsdlfile, namespace)
#Setting the driver to dump debug information to the console
driver.wiredump_dev = STDERR
#Setting the encoding style to ASPDotNetHandler encoding style. Failing to do so will return null username and password in the web service.
driver.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
#Initialize the handler for web method in the client
driver.add_method_with_soapaction(webmethod, soapoperation, param1, param2)
#Invoke the web method and retrieve the return value
result = driver.HelloWorld(fname, lname)

Below error I get when running this program,

Wire dump:

= Request

! CONNECT TO 10.1.12.96:80
! CONNECTION ESTABLISHED
POST /satya/service1.asmx?WSDL HTTP/1.1

SOAPAction: "http://tempuri.org/HelloWorld"

Content-Type: text/xml; charset=utf-8

User-Agent: SOAP4R/1.6.1-SNAPSHOT (2.2.5, ruby 1.8.6 (2007-03-13) [i386-mswin32])

Accept: */*

Date: Tue, 29 May 2012 12:35:31 GMT

Content-Length: 396

Host: 10.1.12.96



<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:HelloWorld xmlns:n1="http://tempuri.org/">
      <n1:fname>senthil</n1:fname>
      <n1:lname>raj</n1:lname>
    </n1:HelloWorld>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 100 Continue

Server: Microsoft-IIS/5.1

Date: Tue, 29 May 2012 12:38:42 GMT

X-Powered-By: ASP.NET; Sitecore CMS

X-Powered-By: ASP.NET



HTTP/1.1 200 OK

Server: Microsoft-IIS/5.1

Date: Tue, 29 May 2012 12:38:42 GMT

X-Powered-By: ASP.NET; Sitecore CMS

X-Powered-By: ASP.NET

X-AspNet-Version: 2.0.50727

Cache-Control: private, max-age=0

Content-Type: text/xml; charset=utf-8

Content-Length: 359



! CONNECTION CLOSED
C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:43:in `gets': execution expired (HTTPClient::ReceiveTimeoutError)
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:879:in `parse_header'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/timeout.rb:131:in `timeout'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:852:in `parse_header'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:835:in `read_header'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient/session.rb:652:in `get_header'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1114:in `do_get_header'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:1063:in `do_get_block'
    from C:/Ruby/lib/ruby/gems/1.8/gems/httpclient-2.2.5/lib/httpclient.rb:869:in `do_request'
     ... 7 levels...
    from C:/Ruby/lib/ruby/gems/1.8/gems/mumboe-soap4r-1.5.8.5/lib/soap/rpc/proxy.rb:149:in `call'
    from C:/Ruby/lib/ruby/gems/1.8/gems/mumboe-soap4r-1.5.8.5/lib/soap/rpc/driver.rb:151:in `call'
    from (eval):6:in `HelloWorld'
    from WStest1.rb:26

WSDL is,

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="HelloWorld">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="s1" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="s2" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld"/>
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse"/>
</wsdl:message>
<wsdl:portType name="Service1Soap">
<wsdl:operation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn"/>
<wsdl:output message="tns:HelloWorldSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Service1Soap" type="tns:Service1Soap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="HelloWorld">
<soap:operation soapAction="http://tempuri.org/HelloWorld" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="HelloWorld">
<soap12:operation soapAction="http://tempuri.org/HelloWorld" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Service1">
<wsdl:port name="Service1Soap" binding="tns:Service1Soap">
<soap:address location="http://10.1.12.96/satya/service1.asmx"/>
</wsdl:port>
<wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
<soap12:address location="http://10.1.12.96/satya/service1.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


Any help regarding this would be appreciated..

Thanks and Regards,
Sathiya.rails