From: Maarten Boonen Date: 2005-01-10T22:26:21+09:00 Subject: Soap - connecting applications --------------040806040305010904060900 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------040806040305010904060900 Content-Type: text/plain; name="HelloService.cs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="HelloService.cs" 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 --------------040806040305010904060900 Content-Type: text/plain; name="client.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="client.rb" #!/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') --------------040806040305010904060900 Content-Type: text/plain; name="server.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="server.rb" #!/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 --------------040806040305010904060900--