Soap4r and ASP.NET problems

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

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

···

On 9/8/05, Pete Elmore <pete@petta-tech.com> wrote:

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&quot;, '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&quot;
xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot;
xmlns:soap="Error;
   <soap:Body>
     <GetVenues xmlns="http://tickettechnology/&quot;&gt;
       <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="Error;
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   <env:Body>
     <n1:GetVenues xmlns:n1="http://tickettechnology/&quot;&gt;
       <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

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

Pete Elmore schrieb:

···

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&quot;, '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&quot; xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:soap="Error;
  <soap:Body>
    <GetVenues xmlns="http://tickettechnology/&quot;&gt;
      <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="Error;
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
  <env:Body>
    <n1:GetVenues xmlns:n1="http://tickettechnology/&quot;&gt;
      <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

Ben Myles wrote:

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

Roland Schmitt wrote:
> 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. :frowning:

Pete Elmore schrieb:

Ben Myles wrote:

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

Roland Schmitt wrote:
> 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. :frowning:

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&quot; xmlns:env="Error; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   <env:Body>
     <n1:SayHello xmlns:n1="http://localhost/WebService/&quot; env:encodingStyle="Error;
       <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&quot; xmlns:env="Error; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
   <env:Body>
     <n1:SayHello xmlns:n1="http://localhost/WebService/&quot;&gt;
       <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/&#39;\)
     @driver.default_encodingstyle = SOAP::EncodingStyle::ASPDotNetHandler::Namespace
     @driver.add_method_with_soapaction
     ('SayHello','http://localhost/WebService/SayHello’,'name&#39;\)
     puts("Ergebnis: " + @driver.SayHello("Mike"))
   end
end

Test.new()

Roland Schmitt wrote:

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.

Hi,
Pete Elmore wrote:

Roland Schmitt wrote:

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.

Or look at http://groups.google.com/group/soap4r/\. NaHi has build a new snapshot (http://dev.ctor.org/download/soap4r-20050911.tar.gz\) which works for me after installing http-access2.

Thanks again, NaHi.

Regards,
Roland