Re: using SOAP::SOM to parse a LWP::UserAgent response

"Garry Williams" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
On 11/7/06, J Cook <[email protected]> wrote:
>
> Garry T. Williams wrote:
> > On Monday 06 November 2006 17:26, J Cook wrote:
> >> I have a LWP::UserAgent request that I want the response to become a
> >> SOAP::SOM object. Is this possible?
> >>
> >> I've tried the following but got a weird SOAP/Lite error:
> >>
> >> $response = $ua->request($request);
> >> $som = SOAP::SOM->new($response->content());
> >> print $som->valueof('//Result/Data');
>     Yes, it might help;) - I got the following:
> Can't use string ("<?xml version="1.0" encoding="ut") as an ARRAY ref
> while "strict refs" in use at /usr/local/share/perl/5.8.7/SOAP/Lite.pm
> line 459.

Well, my version of SOAP::Lite (0.67) is different than yours, so that
line number isn't helping me, but...

This from the SOAP::SOM manual page:

       Objects from the SOAP::SOM class aren't generally instantiated directly
       by an application. Rather, they are handed back by the deserialization
       of a message. In other words, developers will almost never do this:

           $som = SOAP::SOM->new;

       SOAP::SOM objects are returned by a SOAP::Lite call in a client con-
       text. For example:

           my $client = SOAP::Lite
               ->readable(1)
               ->uri($NS)
               ->proxy($HOST)
           $som = $client->someMethod();

This seems to indicate that you are approaching the problem wrong.  But...

If you really must, the same manual page seems to indicate that you
need to call match() before calling valueof().

I've never done what you are attempting because I've never had the
need.  So I have probably not helped much.  I still think you need to
just call the service directly with SOAP::Lite.  You might be
pleasantly surprised.

> > Any reason you're not just using SOAP::Lite to access the service
> > directly?  It uses LWP under its covers.
> >
>     Because its not a simple SOAP call

Huh?

> and its easier for me to roll it
> myself since that's how the person who wrote the service recommends
> doing it. But it would be nice to get the response back where its easily
> parsable.

-- 
Garry Williams +1 678 656-4579
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.