[Rails] Invoke .Net WebService error in RoR

Li Jie
Sun, 14 May 2006 11:55:55 -0000

I have written a webservice:

----------- Service.cs ----------------
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    [WebMethod]
    public string HelloWorld(string name) {
        return "Hello, " + name;
    }

}
--------------- END of Servcie.cs --------------------

In test_api.rb:
api_method :HelloWorld, :expects => [{:name => :string}], :returns =>
[:string]

In test_controller:
  web_client_api :test, :soap, "http://localhost/test/Service.asmx",
                 :namespace => "http://tempuri.org/",
                 :soap_action_base => "http://tempuri.org",
                 :driver_options=>{:default_encodingstyle =>
SOAP::EncodingStyle::ASPDotNetHandler::Namespace }

  def hello
    render_text test.HelloWorld("Li Jie")
  end

It works, but parameters is wrong, the name is null.

I have added some code in rubylib/soap/rpc/proxy.rb:

  def route(req_header, req_body, reqopt, resopt)
    #......
    conn_data.send_string.gsub!(/:n1/, '''')   #ADD
    conn_data.send_string.gsub!(/n1:/, '''')   #ADD

    conn_data = @streamhandler.send(@endpoint_url, conn_data,
    #.....

It removes the namespace ''n1'', and it works find. But I think
this is
wrong way, can anyone fix it?