[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Soap - connecting applications

Maarten Boonen

1/10/2005 1:24:00 PM

Hi,

I made an application in Ruby and want to provide an interface for other
(local) applications to use it. I tried to use SOAP for this purpose (a
good choice?) and it works great with a ruby server and ruby client. But
when i create a C# application to access the ruby server, I can connect
and execute the ruby method, but the result returned is an empty string.
(instead of, for instance, the 'hello world' the server sent out).
Does anybody know whether this is because of some incompatibility
between the message sent and expected by the c# client, or because I
made an error in my c# code? (which I shamelessly copied and slightly
adapted from an online tutorial)

I attached the code of a simple ruby soap server offering a method
'hello(name)', a (working) ruby client, accessing this method, and a c#
app that sends out a request hello("Robert"), but gets an empty string
as result.

Any help is very much appreciated.


Regards,

Maarten
namespace HelloService
{
using System.Diagnostics;
using System.Xml.Serialization;
using System;
using System.Web.Services;
using System.Web.Services.Protocols;

[System.Web.Services.WebServiceBindingAttribute(
Name="SuperDuperTest",
Namespace="www.superdupertest.com")]

public class HelloProxy: System.Web.Services.Protocols.SoapHttpClientProtocol
{
public HelloProxy()
{
this.Url = "http://localhost:9999/";
}

[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
"www.superdupertest.com/hello",
RequestNamespace="www.superdupertest.com",
ResponseNamespace="www.superdupertest.com",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string hello(string name)
{
object [] results = this.Invoke("hello",new object[] { name });
return ((string)(results[0]));
}

[STAThread]
static void Main()
{
HelloProxy service = new HelloProxy();
Console.WriteLine("--->" + service.hello("Robert") + "<---");
}
}
}//End of HelloService Namespace#!/usr/bin/env ruby

require 'soap/rpc/driver'

Name = 'SuperDuperTest'
Namespace = 'www.superdupertest.com'

proxy = SOAP::RPC::Driver.new("http://localhost:9999", Namespace)
proxy.add_method('hello','name')

puts proxy.hello('Jos')
#!/usr/bin/env ruby

require 'soap/rpc/standaloneServer'

$stdout.sync=true

Name = 'SuperDuperTest'
Namespace = 'www.superdupertest.com'

class SuperDuper

def hello(name)
puts result = 'Hi, ' + name
return result
end

end

class SuperServer < SOAP::RPC::StandaloneServer

def on_init
sd = SuperDuper.new
add_method(sd,'hello','name')
end
end

svr = SuperServer.new(Name, Namespace, '0.0.0.0', 9999)
trap('INT') { svr.shutdown }
svr.start


1 Answer

Maarten Boonen

1/10/2005 2:01:00 PM

0

Roland Schmitt schreef:
> you must provide the
> [System.Web.Services.Protocols.SoapRpcMethod()]
> Attribute to your methods like in the example attached.

Thanks! Works like a charm.


Regards,

Maarten