soap4r and ASP.NET problems

P

Pete Elmore

Hello,

I'm having some difficulty getting Ruby to be able to successfully talk
to an ASP.NET application. (The answer to this question may be totally
obvious to someone familiar with XML, SOAP, etc.; sorry if my question
is a bit naive.) I was hoping someone might be able to help.

I'm getting a SOAP::FaultError trying to send a simple request to the
ASP.NET application. My test code looks like this:

require 'soap/rpc/driver'
sd = SOAP::RPC::Driver.new serv_url, namespace
sd.add_method_with_soapaction_as('get_venues', 'GetVenues',
'http://tickettechnology/GetVenues", 'UserName', 'Password',
'DomainName', 'bVerbose')
sd.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace
sd.generate_explicit_type = false
sd.get_venues username, password, domain_name, false

which yields:
SOAP::FaultError: Server was unable to process request. --> Validating
User Name: the submitted user name contains forbidden characters: null
string

The data the server expects looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetVenues xmlns="http://tickettechnology/">
<UserName>string</UserName>
<Password>string</Password>
<DomainName>string</DomainName>
<bVerbose>boolean</bVerbose>
</GetVenues>
</soap:Body>
</soap:Envelope>

But my code is generating this:
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:GetVenues xmlns:n1="http://tickettechnology/">
<UserName>username</UserName>
<Password>password</Password>
<DomainName>domainname</DomainName>
<bVerbose>false</bVerbose>
</n1:GetVenues>
</env:Body>
</env:Envelope>

(Of course, I cut out the actual username and password.)

It looked to me as if it was not finding the username string, since it
was definitely not null. Having very little knowledge of XML/SOAP, my
guess was that the problem was the 'n1:' bit, and so I spent the better
part of today trying to figure out how to get rid of it, with no
success. Any help at all would be greatly appreciated.

Thanks,
Pete
 
R

Roland Schmitt

Hi,

i had problems with the namespace declarations too when using soap4r
version 1.5.4 and Suns JWSDP web services, but ASP.NET works.
With 1.5.4 there are no namespaces "n1:" in the soap body, so i think
you can try this version.

Regards,
Roland
 
P

Pete Elmore

Ben said:
I had some problems with soap4r and asp.net too. Try the latest
snapshot: http://dev.ctor.org/download/soap4r-20050722.tar.gz

Roland said:
Hi,

i had problems with the namespace declarations too when using soap4r
version 1.5.4 and Suns JWSDP web services, but ASP.NET works.
With 1.5.4 there are no namespaces "n1:" in the soap body, so i think
you can try this version.

Thanks for your responses! Unfortunately, the 'n1:' still appears and
the request still fails. I've tried it both under 1.8.2 and 1.8.3
preview 2, with the newest version of soap4r (on three separate OSs),
with identical results. A few of the samples in the source tree (icd
was the one I looked at most closely, since it seems closest to what I'm
trying to do) appear broken, too. :(
 
R

Roland Schmitt

Pete said:
Thanks for your responses! Unfortunately, the 'n1:' still appears and
the request still fails. I've tried it both under 1.8.2 and 1.8.3
preview 2, with the newest version of soap4r (on three separate OSs),
with identical results. A few of the samples in the source tree (icd
was the one I looked at most closely, since it seems closest to what I'm
trying to do) appear broken, too. :(

Hi,
sorry, you are right. I've tested a ASP.NET service with both soap4r
1.5.4 and the version that ships with ruby 1.8.2 (i think soap4r 1.5.3).
With 1.5.3 all env:Body elements have the namespace n1, with 1.5.4 not.
As a result, the ASP.NET service did not find the parameters, because of
the missing namespace, and sets the parametera to "null". So, with 1.5.3
the return value of ASP.NET in this example is "Hello, Mike", with 1.5.4
it return only "Hello,".

Here are the results.

With 1.5.4:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:SayHello xmlns:n1="http://localhost/WebService/"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<name xsi:type="xsd:string">Mike</name>
</n1:SayHello>
</env:Body>
</env:Envelope>


And with 1.5.3:

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:SayHello xmlns:n1="http://localhost/WebService/">
<n1:name>Mike</n1:name>
</n1:SayHello>
</env:Body>
</env:Envelope>

The code is:

require "soap/rpc/driver"
include SOAP::RPC

class Test
def initialize()
@driver =
Driver.new('http://127.0.0.1:80/WebService/Service1.asmx','http://localhost/WebService/')
@driver.default_encodingstyle =
SOAP::EncodingStyle::ASPDotNetHandler::Namespace
@driver.add_method_with_soapaction
('SayHello','http://localhost/WebService/SayHello','name')
puts("Ergebnis: " + @driver.SayHello("Mike"))
end
end

Test.new()
 
P

Pete Elmore

Roland said:
Hi,
sorry, you are right. I've tested a ASP.NET service with both soap4r
1.5.4 and the version that ships with ruby 1.8.2 (i think soap4r 1.5.3).
With 1.5.3 all env:Body elements have the namespace n1, with 1.5.4 not.
As a result, the ASP.NET service did not find the parameters, because of
the missing namespace, and sets the parametera to "null". So, with 1.5.3
the return value of ASP.NET in this example is "Hello, Mike", with 1.5.4
it return only "Hello,".
Thanks! Downgrading soap4r seems to have fixed the problem, and I'm happily
sending remote procedure calls left and right.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top