Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Ruby SOAP client communication with Microsoft .NET webservice

Reply
Thread Tools

Ruby SOAP client communication with Microsoft .NET webservice

 
 
Kishore
Guest
Posts: n/a
 
      12-10-2005
Hi:

I am trying to interface a SOAP client written in Ruby with a .NET
webservice. However, I am unable to get the client to construct the
correct SOAP request for methods with one string argument. My ruby
client file has the following code:

require 'soap/wsdlDriver'
require 'cgi'

WSDL_URL = "http://instrument1/orbitws/orbitinterferencews.asmx?WSDL"
soap_client = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_d river

# Log SOAP request and response
soap_client.wiredump_file_base = "soap-log.txt"

# Call reset method.
result = soap_client.resetIntWS(nil)
puts result.inspect

# Call stopGenerate method.
result = soap_client.stopGenerate('1')
puts result.inspect

The first method call works but the second one fails to construct the
SOAP request with the single argument. We tried using double quotes as
well but that did not work either.

The SOAP request we want should like like:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<stopGenerate xmlns="http://instrument1.orbit-lab.org/OrbitWS/">
<request_id>string</request_id>
</stopGenerate>
</soap:Body>
</soap:Envelope>

However, our SOAP request looks like:

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:stopGenerate
xmlns:n1="http://instrument1.orbit-lab.org/OrbitWS/">
</n1:stopGenerate>
</env:Body>
</env:Envelope>

Note that the "<request_id>string</request_id>" is missing. Can you
please tell me why this is happening. I am using ruby v1.8.4 on a
debian linux 2.6.11-1-686-smp.

Thanks,
Kishore

 
Reply With Quote
 
 
 
 
Kero
Guest
Posts: n/a
 
      12-10-2005
><?xml version="1.0" encoding="utf-8"?>
><soap:Envelope xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <stopGenerate xmlns="http://instrument1.orbit-lab.org/OrbitWS/">
> <request_id>string</request_id>
> </stopGenerate>
> </soap:Body>
></soap:Envelope>
>
> However, our SOAP request looks like:
>
><?xml version="1.0" encoding="utf-8" ?>
><env:Envelope xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> <env:Body>
> <n1:stopGenerate
> xmlns:n1="http://instrument1.orbit-lab.org/OrbitWS/">
> </n1:stopGenerate>
> </env:Body>
></env:Envelope>


How would the call to stopGenerate know that '1' is a request id?

I have had success with using Structs.

Request = Struct.new(:request_id)
soap.stopGenerate(Request.new('1'))

Hth,
Kero.
 
Reply With Quote
 
 
 
 
Kishore
Guest
Posts: n/a
 
      12-10-2005
Hi Kero:

Thanks a lot. That worked out. Would you know how to pass an array of
strings as argument? I am trying to the following:

Request = Struct.new(:request_id, :names, :values)
result = soap_client.stopGenerate(Request.new("1", ["POWER", "FREQ"],
["-15", "5.18GHz"]))
puts result.inspect

This should generate the following SOAP request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Generate xmlns="http://instrument1/OrbitWS/">
<request_id>string</request_id>
<names>
<string>string</string>
<string>string</string>
</names>
<values>
<string>string</string>
<string>string</string>
</values>
</Generate>
</soap:Body>
</soap:Envelope>

However, it creates the following:

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlnssd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:Generate xmlns:n1="http://instrument1.orbit-lab.org/OrbitWS/">
<n1:request_id>1</n1:request_id>
<n1:names>
<n1:string></n1:string>
</n1:names>
<n1:values>
<n1:string></n1:string>
</n1:values>
</n1:Generate>
</env:Body>
</env:Envelope>

Thanks,
Kishore

 
Reply With Quote
 
tsumeruby@tsumelabs.com
Guest
Posts: n/a
 
      12-10-2005
On Sunday 11 December 2005 03:32 am, Kishore wrote:

When using SOAP4R with .NET web services, you must use the ASPDotNetHander.

@my_client.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace

Tsume

> Hi Kero:
>
> Thanks a lot. That worked out. Would you know how to pass an array of
> strings as argument? I am trying to the following:
>
> Request = Struct.new(:request_id, :names, :values)
> result = soap_client.stopGenerate(Request.new("1", ["POWER", "FREQ"],
> ["-15", "5.18GHz"]))
> puts result.inspect
>
> This should generate the following SOAP request:
>
> <?xml version="1.0" encoding="utf-8"?>
> <soap:Envelope xmlnssi="http://www.w3.org/2001/XMLSchema-instance"
> xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
> <soap:Body>
> <Generate xmlns="http://instrument1/OrbitWS/">
> <request_id>string</request_id>
> <names>
> <string>string</string>
> <string>string</string>
> </names>
> <values>
> <string>string</string>
> <string>string</string>
> </values>
> </Generate>
> </soap:Body>
> </soap:Envelope>
>
> However, it creates the following:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <env:Envelope xmlnssd="http://www.w3.org/2001/XMLSchema"
> xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
> xmlnssi="http://www.w3.org/2001/XMLSchema-instance">
> <env:Body>
> <n1:Generate xmlns:n1="http://instrument1.orbit-lab.org/OrbitWS/">
> <n1:request_id>1</n1:request_id>
> <n1:names>
> <n1:string></n1:string>
> </n1:names>
> <n1:values>
> <n1:string></n1:string>
> </n1:values>
> </n1:Generate>
> </env:Body>
> </env:Envelope>
>
> Thanks,
> Kishore



 
Reply With Quote
 
Kero
Guest
Posts: n/a
 
      12-12-2005
> Thanks a lot. That worked out. Would you know how to pass an array of
> strings as argument? I am trying to the following:
>
> Request = Struct.new(:request_id, :names, :values)
> result = soap_client.stopGenerate(Request.new("1", ["POWER", "FREQ"],
> ["-15", "5.18GHz"]))


I have something like
Request = Struct.new(...)
Names = Struct.new(...)
Request.new(1, Names.new(["power", "freq"], Values.new([...])

i.e. the arrays wrapped in their own structs.

However, I needed different soap requests; I got to it after a *detailed*
look (yuck) at the wsdl, I suppose yours might look different. YMMV.

And here my experience ends. I got working what I needed, then stopped
looking.

Bye,
Kero.
 
Reply With Quote
 
Kishore
Guest
Posts: n/a
 
      12-21-2005
Hi Kero:

Thanks for getting back to me. I got it to work after reading through
some of nahi's emails (thanks to him). The steps I followed were as
follows:

1. Download soap4r from SVN.
svn co http://dev.ctor.org/svn/soap4r/trunk/bin soap4r

This will result in two files being downloaded - wsdl2ruby.rb and
xsd2ruby.rb. The one I used was the wsdl2ruby.rb.

2. Generate sample SOAP client file

ruby wsdl2ruby.rb --wsdl http://location_of_WSDL --type client

This will result in the creation of three files - default.rb,
defaultDriver.rb and WSClient.rb. The sample client file is
WSClient.rb. Inside this file, I found all the remote methods and "nil"
arguments being passed to them. For e.g., I had a remote method defined
as follows in my web-service:

string observe (string req_id, string[] names, string[] values);

The second and third argument for this file were vectors of strings.

In the ruby client file, this method was exposed as follows:

obj = WSSoap.new(nil)

parameters = nil
puts obj.observe(parameters)

So, even though my remote method should have three arguments, here
there is only one. According to nahi's email, I needed to construct a
hash table and pass that as the single argument.

3. Pass actual arguments.
name = ['CENTER', 'SPAN', 'SCALE', 'YREF', 'INTERVAL']
val = ['5.18 GHz', '2.95 MHz', '4.00', '-68.70', '30000']
parameters = {
'req_id' => '1',
'names' => {:string => name},
'values' => {:string => val}
}
result = obj.observe(parameters)
puts result.inspect

Hope that helps,
Kishore

Kero wrote:
> > Thanks a lot. That worked out. Would you know how to pass an array of
> > strings as argument? I am trying to the following:
> >
> > Request = Struct.new(:request_id, :names, :values)
> > result = soap_client.stopGenerate(Request.new("1", ["POWER", "FREQ"],
> > ["-15", "5.18GHz"]))

>
> I have something like
> Request = Struct.new(...)
> Names = Struct.new(...)
> Request.new(1, Names.new(["power", "freq"], Values.new([...])
>
> i.e. the arrays wrapped in their own structs.
>
> However, I needed different soap requests; I got to it after a *detailed*
> look (yuck) at the wsdl, I suppose yours might look different. YMMV.
>
> And here my experience ends. I got working what I needed, then stopped
> looking.
>
> Bye,
> Kero.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
client-to-client communication via SOAP Bruce ASP .Net Web Services 3 03-28-2005 02:31 AM
client-to-client communication via SOAP Bruce ASP .Net Web Services 0 03-24-2005 06:37 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57