# NANWSI: Not Another .NET Web Service Issue

**URL:** <https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287>\
**Category:** Ruby\
**Created:** [October 14, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287 "2009-10-14T15:23:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [October 14, 2009, 3:23pm UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/1 "2009-10-14T15:23:29Z")

</div>

Hi all,

I’m still quite new to Ruby, I come from years of “evil” development (MS  
and .NET).  
I am using ruby1.9.1 and soap4r to communicate with a .NET web service.

I’ve seen several posts, several advices, several “solutions”; I tried  
them all, and still it doesn’t work…  
I’ve been trying different approaches for a couple of days now, and I  
feel I am getting stuck.

My dumb web service is here: [http://78.136.25.213/Test/ws/Service.asmx](http://78.136.25.213/Test/ws/Service.asmx)  
From here you can get its WSDL:  
[http://78.136.25.213/Test/ws/Service.asmx?wsdl](http://78.136.25.213/Test/ws/Service.asmx?wsdl)

It’s a basic ws that expects a single string parameter (“inputString”)  
as input and returns a single string as output. That simple (this is a  
test of course).

## This is the code of my client:

require “soap/rpc/driver”  
require “RechnerServiceModule”  
include RechnerServiceModule

## server = ‘[http://78.136.25.213/Test/ws/Service.asmx](http://78.136.25.213/Test/ws/Service.asmx)’ wiredump\_dev=STDERR service = SOAP::RPC::Driver.new(server, RechnerServiceModule::InterfaceNS) service.use\_default\_namespace = true service.default\_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace service.wiredump\_dev=wiredump\_dev RechnerServiceModule::add\_method(service) result = service.TestWS(:parameter =\> “testString”) print("Result: ", result)

This is the RechnerServiceModule:

* * *

###file:servicemodule.rb  
module RechnerServiceModule  
InterfaceNS = ‘[Bing](http://tempuri.org/TestWS)’  
Methods=[[‘TestWS’, ‘inputString’]]

## def RechnerServiceModule.add\_method(drv) Methods.each do |method, \*param| drv.add\_method\_with\_soapaction(method, InterfaceNS, \*param) end end end

Looking at the wiredump I see that this is the SOAP XML sent (which  
apparently is identical to the one .NET expects - on the TestWS web  
page: [http://78.136.25.213/Test/ws/Service.asmx?op=TestWS](http://78.136.25.213/Test/ws/Service.asmx?op=TestWS)):

* * *
\<?xml version="1.0" encoding="utf-8" ?\>\<soap:Envelope
## xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)” xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)” xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\> soap:Body testString \</soap:Body\>\</soap:Envelope\>

Unfortunately I keep on receiving an error, as you can see in the  
response:

* * *

HTTP/1.1 500 Internal Server Error  
Date: Wed, 14 Oct 2009 13:07:26 GMT  
Server: Microsoft-IIS/6.0  
X-Powered-By: [ASP.NET](http://ASP.NET)  
X-AspNet-Version: 2.0.50727  
Cache-Control: private  
Content-Type: text/xml; charset=utf-8  
Content-Length: 433

\<?xml version="1.0" encoding="utf-8"?\>\<soap:Envelope

xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”\>soap:Bodysoap:Faultsoap:ServerServer  
was unable to process request. —\> Value cannot be null.  
Parameter name: String\</soap:Fault\>\</soap:Body\>\</soap:Envelope\>

: Server was unable to process request. —\> Value cannot be null.  
(SOAP::FaultError)  
Parameter name: String

Process finished with exit code 1

* * *

I tried the approach of generating the WSDL proxy, and this is the error  
I received:

* * *

## wsdl2ruby.rb --wsdl [http://78.136.25.213/Test/ws/Service.asmx?wsdl](http://78.136.25.213/Test/ws/Service.asmx?wsdl) –type client --force ignored element: {[http://schemas.xmlsoap.org/wsdl/soap12/](http://schemas.xmlsoap.org/wsdl/soap12/)}binding ignored element: {[http://schemas.xmlsoap.org/wsdl/soap12/](http://schemas.xmlsoap.org/wsdl/soap12/)}operation ignored element: {[http://schemas.xmlsoap.org/wsdl/soap12/](http://schemas.xmlsoap.org/wsdl/soap12/)}body ignored element: {[http://schemas.xmlsoap.org/wsdl/soap12/](http://schemas.xmlsoap.org/wsdl/soap12/)}address I, [2009-10-14T14:58:09.237427 #35258] INFO – app: Creating class definition. I, [2009-10-14T14:58:09.237637 #35258] INFO – app: Creates file ‘default.rb’. F, [2009-10-14T14:58:09.239160 #35258] FATAL – app: Detected an exception. Stopping … undefined method `collect' for "{http://tempuri.org/}TestWS\n inputString - SOAP::SOAPString":String (NoMethodError) /usr/lib/Ruby1.9/rubygems-1.3.5/gems/soap4r-1.5.8/lib/xsd/codegen/gensupport.rb:239:in `trim\_eol’ … etc

So, if anybody has the solution to this, I would really love to hear  
that, since this is killing me now…

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [October 16, 2009, 11:55am UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/2 "2009-10-16T11:55:06Z")

</div>

I guess nobody has the answer to this, hence nobody was able to make  
soap4r working with .NET web services?  
Anybody could please suggest me a working SOAP library for Ruby that  
works for real with .NET ws?  
Sure appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [October 16, 2009, 7:56pm UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/3 "2009-10-16T19:56:43Z")

</div>

On 16 Oct 2009, at 11:55, Massimo B. wrote:

> I guess nobody has the answer to this, hence nobody was able to make  
> soap4r working with .NET web services?  
> Anybody could please suggest me a working SOAP library for Ruby that  
> works for real with .NET ws?  
> Sure appreciated, thanks!

I’ve been successful in using various wsdl’s for communicating with  
some services which are also .NET based afaik. I’ve used wsdl2ruby.rb  
in all cases and it didn’t fail on the wsdl’s I’ve given it.

But I’d probably use this now if I need to write additional clients:

> **[GitHub - unwire/handsoap: Handsoap is a library for creating SOAP clients in...](https://github.com/unwire/handsoap/)**
>
> Handsoap is a library for creating SOAP clients in Ruby - GitHub - unwire/handsoap: Handsoap is a library for creating SOAP clients in Ruby

I’d suggest giving it a try to see if it fits your needs.

–  
Regards,

Dirkjan Bussink

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [October 17, 2009, 12:44am UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/4 "2009-10-17T00:44:08Z")

</div>

On Fri, Oct 16, 2009 at 5:55 AM, Massimo B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I guess nobody has the answer to this, hence nobody was able to make  
> soap4r working with .NET web services?  
> Anybody could please suggest me a working SOAP library for Ruby that  
> works for real with .NET ws?  
> Sure appreciated, thanks!

Sorry, for the delay. I also haved used soap4r successfully in the  
past to talk to .net web services. After your initial post, I grabbed  
your wsdl and ran it through wsdl2ruby, the result was the same as  
yours: the request appeared identical to the sample request provided  
by the web service but the response was parameter String cannot be  
NULL.

I would recommend trying another library such as suggested by Dirkjan  
Bussink. Also, are you certain that the service itself is not the  
issue (e.g. it appears that the error references a parameter named  
String but the request only has a parameter testString)?

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [October 19, 2009, 11:24am UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/5 "2009-10-19T11:24:17Z")

</div>

unknown wrote:

> On Fri, Oct 16, 2009 at 5:55 AM, Massimo B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I guess nobody has the answer to this, hence nobody was able to make  
> > soap4r working with .NET web services?  
> > Anybody could please suggest me a working SOAP library for Ruby that  
> > works for real with .NET ws?  
> > Sure appreciated, thanks!
> 
> Sorry, for the delay. I also haved used soap4r successfully in the  
> past to talk to .net web services. After your initial post, I grabbed  
> your wsdl and ran it through wsdl2ruby, the result was the same as  
> yours: the request appeared identical to the sample request provided  
> by the web service but the response was parameter String cannot be  
> NULL.
> 
> I would recommend trying another library such as suggested by Dirkjan  
> Bussink. Also, are you certain that the service itself is not the  
> issue (e.g. it appears that the error references a parameter named  
> String but the request only has a parameter testString)?

Thanks,

unknown: you were right, it was totally my fault!  
I was too busy debugging this “new” (to me) Ruby library that I didn’t  
bother checking for issues in the web service.  
Well, the problem was actually there…  
Sorry about this, my bad.

Dirkjan: thank you much, I’ll keep handsoap in mind in case I need  
another soap library.

For now it works just fine with soap4r!  
Thanks all!

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [May 7, 2010, 8:38pm UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/6 "2010-05-07T20:38:42Z")

</div>

I did exactly what noisefree did but getting below error

Fast Debugger (ruby-debug-ide 0.4.6) listens on localhost:3509  
JRuby limited openssl loaded. gem install jruby-openssl for full  
support.  
[http://jruby.kenai.com/pages/JRuby\_Builtin\_OpenSSL](http://jruby.kenai.com/pages/JRuby_Builtin_OpenSSL)  
Wire dump:

opening connection to 192.168.24.76…  
opened  
 ← “POST /BSSWebService/Test.asmx HTTP/1.1\r\nContent-Type: text/xml;  
charset=utf-8\r\nSoapaction:  
"[Bing](http://tempuri.org/MyName%5C)”\r\nUser-Agent: SOAP4R/1.5.5\r\nAccept:  
_/_\r\nHost: 192.168.24.76\r\nContent-Length: 368\r\n\r\n"  
 ← “\<?xml version=\"1.0\" encoding=\"utf-8\" ?\>\n\<env:Envelope  
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance\](http://www.w3.org/2001/XMLSchema-instance%5C)”\n  
xmlns:xsd="[http://www.w3.org/2001/XMLSchema\](http://www.w3.org/2001/XMLSchema%5C)“\n  
xmlns:env="[http://schemas.xmlsoap.org/soap/envelope/\](http://schemas.xmlsoap.org/soap/envelope/%5C)”\>\n env:Body\n  
\<n1:MyName xmlns:n1="[Bing](http://tempuri.org/MyName%5C)“\>\n  
n1:inpstrtestString\</n1:inpstr\>\n \</n1:MyName\>\n  
\</env:Body\>\n\</env:Envelope\>”  
 → “HTTP/1.1 500 Internal Server Error\r\n”  
 → “Date: Fri, 07 May 2010 18:28:15 GMT\r\n”  
 → “Server: Microsoft-IIS/6.0\r\n”  
 → “X-Powered-By: [ASP.NET](http://ASP.NET)\r\n”  
 → “X-AspNet-Version: 2.0.50727\r\n”  
 → “Cache-Control: private\r\n”  
 → “Content-Type: text/xml; charset=utf-8\r\n”  
 → “Content-Length: 934\r\n”  
 → “\r\n”  
reading 934 bytes…  
 → “\<?xml version=\"1.0\" encoding=\"utf-8\"?\>\<soap:Envelope  
xmlns:soap="[http://schemas.xmlsoap.org/soap/envelope/\](http://schemas.xmlsoap.org/soap/envelope/%5C)”  
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance\](http://www.w3.org/2001/XMLSchema-instance%5C)"  
xmlns:xsd="[http://www.w3.org/2001/XMLSchema\](http://www.w3.org/2001/XMLSchema%5C)“\>soap:Bodysoap:Faultsoap:ClientSystem.Web.Services.Protocols.SoapException:  
Server did not recognize the value of HTTP Header SOAPAction:  
[Bing](http://tempuri.org/MyName.%5Cr%5Cn) at  
System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()\r\n  
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()\r\n  
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,  
HttpContext context, HttpRequest request, HttpResponse response)\r\n  
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type,  
HttpContext context, HttpRequest request, HttpResponse response,  
Boolean& abortProcessing)\</soap:Fault\>\</soap:Body\>\</soap:Envelope\>”  
read 934 bytes  
Conn keep-alive

\<?xml version="1.0" encoding="utf-8"?\>\<soap:Envelope 

xmlns:soap=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”  
xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”\>soap:Bodysoap:Faultsoap:ClientSystem.Web.Services.Protocols.SoapException:  
Server did not recognize the value of HTTP Header SOAPAction:  
[Bing](http://tempuri.org/MyName).  
at  
System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()  
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()  
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,  
HttpContext context, HttpRequest request, HttpResponse response)  
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type  
type, HttpContext context, HttpRequest request, HttpResponse response,  
Boolean& abortProcessing)\</soap:Fault\>\</soap:Body\>\</soap:Envelope\>

: System.Web.Services.Protocols.SoapException: Server did not recognize  
the value of HTTP Header SOAPAction: [Bing](http://tempuri.org/MyName).  
(SOAP::FaultError)  
at  
System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()  
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()  
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type,  
HttpContext context, HttpRequest request, HttpResponse response)  
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type  
type, HttpContext context, HttpRequest request, HttpResponse response,  
Boolean& abortProcessing)

What could be the problem

My code

module RechnerServiceModule  
InterfaceNS = ‘[Bing](http://tempuri.org/MyName)’  
Methods=[[‘MyName’,‘inpstr’]]

def RechnerServiceModule.add\_method(drv)  
Methods.each do |method, \*param|  
drv.add\_method\_with\_soapaction(method, InterfaceNS, \*param)

```
  end

```

end  
end  
require ‘rubygems’  
require “soap/rpc/driver”  
#require “RechnerServiceModule”  
include RechnerServiceModule

server = ‘[http://192.168.24.76/BSSWebService/Test.asmx](http://192.168.24.76/BSSWebService/Test.asmx)’  
wiredump\_dev=STDERR  
service = SOAP::RPC::Driver.new(server,  
RechnerServiceModule::InterfaceNS)  
#service.use\_default\_namespace = true  
service.default\_encodingstyle =  
SOAP::EncodingStyle::ASPDotNetHandler::Namespace  
service.wiredump\_dev=wiredump\_dev  
RechnerServiceModule::add\_method(service)  
result = service.MyName(“testString”)

print("Result: ", result)

---

<div class="post-metadata">

**Author:** ![noisefree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3e96dc/32.png) [@noisefree](https://www.ruby-forum.com/u/noisefree)\
**Post date:** [May 8, 2010, 6:54am UTC](https://www.ruby-forum.com/t/nanwsi-not-another-net-web-service-issue/177287/7 "2010-05-08T06:54:09Z")

</div>

I’m not intimately familiar with this library, but I would be  
interested to know if it works properly on a non-JRuby setup. If it  
does, it would be a bug we would want to fix in JRuby. If it does not,  
then it’s probably an issue with the library…
