Forum: Ruby Ruby SOAP client communication with Microsoft .NET webservic

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
5f08f034dd0c7fccb36fa376d1fc106f?d=identicon&s=25 keyshawn (Guest)
on 2005-12-10 01:45
(Received via mailing list)
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.asm...
soap_client = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver

# 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="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 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: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
Dd54c22454b4e3c21cadf3bdb5192e28?d=identicon&s=25 kero (Guest)
on 2005-12-10 09:14
(Received via mailing list)
>
>  </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.
5f08f034dd0c7fccb36fa376d1fc106f?d=identicon&s=25 keyshawn (Guest)
on 2005-12-10 19:36
(Received via mailing list)
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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="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 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: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
19f65b7dca6831edf989224b5ebd3fe0?d=identicon&s=25 tsumeruby (Guest)
on 2005-12-10 23:32
(Received via mailing list)
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
Dd54c22454b4e3c21cadf3bdb5192e28?d=identicon&s=25 Kero (Guest)
on 2005-12-12 09:28
(Received via mailing list)
> 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.
5f08f034dd0c7fccb36fa376d1fc106f?d=identicon&s=25 Kishore (Guest)
on 2005-12-21 19:44
(Received via mailing list)
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
This topic is locked and can not be replied to.