Forum: Ruby on Rails Problem Consuming a Web Service

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Josh C. (Guest)
on 2006-05-17 22:01
(Received via mailing list)
I'm trying to consume a webservice from my rails application and have
discovered an interesting problem.  I can call webservice functions
just fine, as long as they do not require any arguments, but function
that do require arguments do not work.  The arguments are sent as
either null or an empty string.

My API has these method definitions:

  api_method :otherFunction, :expects=>[{:username=>:string}],
:returns=>[:string]

  api_method :test, :returns=>[:int]

Calling test works perfectly.  When I try to call otherFunction from
my controller, after setting up the soap_client:

   soap_client.otherFunction('name')

Somehow the username parameter is not being filled out properly.  Has
anyone else ran into this?  Is there anyway to test the request that
Rails is sending out?

Thanks,
Josh
unknown (Guest)
on 2006-05-17 22:19
(Received via mailing list)
On 5/17/06, Josh C. <removed_email_address@domain.invalid> wrote:
> I'm trying to consume a webservice from my rails application and have
> discovered an interesting problem.
> ...
> Is there anyway to test the request that Rails is sending out?

soap_client.wiredump_dev = STDERR
Josh C. (Guest)
on 2006-05-18 01:31
(Received via mailing list)
wiredump_dev does not seem to be a valid method...  Is there another
solution?

Thanks,
Josh
unknown (Guest)
on 2006-05-18 01:40
(Received via mailing list)
> > > I'm trying to consume a webservice from my rails application and have
> > > discovered an interesting problem.
> > > ...
> > > Is there anyway to test the request that Rails is sending out?
> >
> > soap_client.wiredump_dev = STDERR
>
> wiredump_dev does not seem to be a valid method...

What SOAP client library are you using?

> Is there another solution?

Use Ethereal to capture a test session.  Select a packet and 'Analyze'
-> 'Follow TCP Stream'.
Josh C. (Guest)
on 2006-05-19 00:32
(Received via mailing list)
Ah, that's a great tool.  I see the problem is that the generated soap
request has alot of strange xml namespace problems.  I don't know what
to make of it yet, but I guess it's a start.

I'm using the
ActionWebService::Client::Soap.new(UmkcApi, "http://...",
:namespace=>"https://..mynamespace",
:driver_options=>{:default_encodingstyle =>
SOAP::EncodingStyle::ASPDotNetHandler::Namespace })

Thanks for your help so far
Frank Cameron (Guest)
on 2006-05-19 00:49
(Received via mailing list)
On 5/18/06, Josh C. <removed_email_address@domain.invalid> wrote:
> Ah, that's [Ethereal] a great tool.

Yes it is; I had to use the same method last night to help track down
a bug in a .net SOAP service.  :-)

>  I see the problem is that the generated soap
> request has alot of strange xml namespace problems.  I don't know what
> to make of it yet, but I guess it's a start.

I had a problem awhile back that was namespace related in SOAP client.
 In my case the problem was I was just sending a Hash as the parameter
for the SOAP call instead of an instance of the Request class that
wsdl2ruby (soap4r) generated for me from the WSDL.

> I'm using the
> ActionWebService::Client::Soap.new(UmkcApi, "http://...",
>   :namespace=>"https://..mynamespace",
>   :driver_options=>{:default_encodingstyle =>
>     SOAP::EncodingStyle::ASPDotNetHandler::Namespace })

I later thought that might be the case; explains why soap4r's
wiredump_dev didn't work. :-)
Josh C. (Guest)
on 2006-05-19 01:18
(Received via mailing list)
I don't understand what is going wrong.  Here is the envelope that is
being sent:

<?xml version="1.0" encoding="us-ascii" ?>
<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:Changed xmlns:n1="https://Changed/"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <username xsi:type="xsd:string">charlesj</username>
    </n1:Changed>
  </env:Body>
</env:Envelope>

When it should simply be 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>
    <Changedo xmlns="https://Changed/">
      <username>string</username>
    </Changed>
  </soap:Body>
</soap:Envelope>


Any ideas on what might be causing this, and how I might be able to
fix it?  I've been looking through the documentation for:
ActionWebService::Client::Soap, but it certainly appears that I've
done everything correctly...  The webservice I'm calling without
parameters works perfectly.

Josh
This topic is locked and can not be replied to.