[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Using .NET web service with soap4r

Roland Schmitt

11/12/2004 1:40:00 PM

Hello,

i try to call a ASP.NET based web service with soap4r.
The call is successful, this means no error is thrown in ruby nor in the web service. The problem is that the value returned is not as expected.

I cut i down to the following:

This is what soap4r sends:

<?xml version="1.0" encoding="us-ascii" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
<env:Body>
<SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
<name xsi:type="xsd:string">Roland</name>
</SayHello>
</env:Body>
</env:Envelope>

This is what the service returns:
...
<SayHelloResult>Hello, </SayHelloResult>
...

This is what i expect:
...
<SayHelloResult>Hello, Roland</SayHelloResult>

If i remove the namespace definition (ns1) by hand in the soap4r call, e.g.
<?xml version="1.0" encoding="us-ascii" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
<env:Body>
<SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
<name xsi:type="xsd:string">Roland</name>
</SayHello>
</env:Body>

i get the correct answer.

Here is my ruby code:
require "soap/rpc/driver"

include SOAP::RPC

class Test
def initialize()
driver = SOAP::RPC::Driver.new('http://localhost:8070/PingService/PingService.asmx','http://localhost/PingService/')
driver.allow_unqualified_element=true
driver.add_method_with_soapaction('SayHello','http://localhost/PingService/SayHello','name')
puts("Ergebnis: ", driver.SayHello("Roland"))
end
end
Test.new

Any hints?

Regards,
Roland




__________________________________________________________
Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
weltweit telefonieren! http://freephone.web.de/...



3 Answers

David Ross

11/12/2004 1:52:00 PM

0

Roland Schmitt wrote:

>Hello,
>
>i try to call a ASP.NET based web service with soap4r.
>The call is successful, this means no error is thrown in ruby nor in the web service. The problem is that the value returned is not as expected.
>
>I cut i down to the following:
>
>This is what soap4r sends:
>
><?xml version="1.0" encoding="us-ascii" ?>
> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
> <env:Body>
> <SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
> <name xsi:type="xsd:string">Roland</name>
> </SayHello>
> </env:Body>
> </env:Envelope>
>
>This is what the service returns:
>...
><SayHelloResult>Hello, </SayHelloResult>
>...
>
>This is what i expect:
>...
><SayHelloResult>Hello, Roland</SayHelloResult>
>
>If i remove the namespace definition (ns1) by hand in the soap4r call, e.g.
><?xml version="1.0" encoding="us-ascii" ?>
> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
> <env:Body>
> <SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
> <name xsi:type="xsd:string">Roland</name>
> </SayHello>
> </env:Body>
>
>i get the correct answer.
>
>Here is my ruby code:
>require "soap/rpc/driver"
>
>include SOAP::RPC
>
>class Test
> def initialize()
> driver = SOAP::RPC::Driver.new('http://localhost:8070/PingService/PingService.asmx','http://localhost/PingService/')
> driver.allow_unqualified_element=true
> driver.add_method_with_soapaction('SayHello','http://localhost/PingService/SayHello','name')
> puts("Ergebnis: ", driver.SayHello("Roland"))
> end
>end
>Test.new
>
>Any hints?
>
>Regards,
>Roland
>
>
>
>

I've never used soap4r with ASP.NET services, but I believe there might
be a missing encoding setting for ASPDotNet.

try..

require "soap/rpc/driver"

include SOAP::RPC

class Test
def initialize()
driver = SOAP::RPC::Driver.new('http://localhost:8070/PingService/PingService.asmx','http://localhost/PingService/')
driver.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
driver.allow_unqualified_element=true
driver.add_method_with_soapaction('SayHello','http://localhost/PingService/SayHello','name')
puts("Ergebnis: ", driver.SayHello("Roland"))
end
end
Test.new

David Ross
--
Hazzle free packages for Ruby?
RPA is available from http://www.rubyar...



Roland Schmitt

11/12/2004 2:09:00 PM

0

Hi,

David Ross wrote:

> I've never used soap4r with ASP.NET services, but I believe there might
I would be lucky, if i could say the same...

> be a missing encoding setting for ASPDotNet.
>
> try..
>
> require "soap/rpc/driver"
>
> include SOAP::RPC
>
> class Test
> def initialize()
> driver =
> SOAP::RPC::Driver.new('http://localhost:8070/PingService/PingService.asmx','http://localhost/PingService/')
>
> driver.default_encodingstyle =
> SOAP::EncodingStyle::ASPDotNetHandler::Namespace

I have tried this, but the result was the same. Also the generated xml
was the same...

> driver.allow_unqualified_element=true
>
> driver.add_method_with_soapaction('SayHello','http://localhost/PingService/SayHello','name')
>
> puts("Ergebnis: ", driver.SayHello("Roland"))
> end end
> Test.new

Thank you,
Roland


rpardee

11/15/2004 1:36:00 AM

0

Be sure and throw a:

Web.Services.Protocols.SoapRpcMethod()

attribute on your web method. Else asp.net will not use rpc encoding.

HTH,

-Roy

"Roland Schmitt" <Roland.Schmitt@web.de> wrote in message news:<1367660503@web.de>...
> Hello,
>
> i try to call a ASP.NET based web service with soap4r.
> The call is successful, this means no error is thrown in ruby nor in the web service. The problem is that the value returned is not as expected.
>
> I cut i down to the following:
>
> This is what soap4r sends:
>
> <?xml version="1.0" encoding="us-ascii" ?>
> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
> <env:Body>
> <SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
> <name xsi:type="xsd:string">Roland</name>
> </SayHello>
> </env:Body>
> </env:Envelope>
>
> This is what the service returns:
> ..
> <SayHelloResult>Hello, </SayHelloResult>
> ..
>
> This is what i expect:
> ..
> <SayHelloResult>Hello, Roland</SayHelloResult>
>
> If i remove the namespace definition (ns1) by hand in the soap4r call, e.g.
> <?xml version="1.0" encoding="us-ascii" ?>
> <env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSc... xmlns:env="http://schemas.xmlsoap.org/soap/envel... xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance...
> <env:Body>
> <SayHello xmlns="http://localhost/PingService/" env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/...
> <name xsi:type="xsd:string">Roland</name>
> </SayHello>
> </env:Body>
>
> i get the correct answer.
>
> Here is my ruby code:
> require "soap/rpc/driver"
>
> include SOAP::RPC
>
> class Test
> def initialize()
> driver = SOAP::RPC::Driver.new('http://localhost:8070/PingService/PingService.asmx','http://localhost/PingService/')
> driver.allow_unqualified_element=true
> driver.add_method_with_soapaction('SayHello','http://localhost/PingService/SayHello','name')
> puts("Ergebnis: ", driver.SayHello("Roland"))
> end
> end
> Test.new
>
> Any hints?
>
> Regards,
> Roland
>
>
>
>
> __________________________________________________________
> Mit WEB.DE FreePhone mit hoechster Qualitaet ab 0 Ct./Min.
> weltweit telefonieren! http://freephone.web.de/...