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

Hi,

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');

Any suggestions?

TIA

Justin
jcook713 [ Mo, 06 November 2006 23:26 ] [ ID #1526348 ]

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

Garry T. Williams wrote:
> On Monday 06 November 2006 17:26, J Cook wrote:
>
>> Hi,
>>
>> 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');
>>
>
> Of course this might be easier, if you included the text of the error
> you refer to. :-)
>
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.


>> Any suggestions?
>>
>
> 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 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.
jcook713 [ Di, 07 November 2006 15:13 ] [ ID #1527648 ]

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

On 11/7/06, J Cook <jcook713 [at] comcast.net> 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
gtwilliams [ Di, 07 November 2006 16:22 ] [ ID #1527649 ]
Perl » perl.libwww » using SOAP::SOM to parse a LWP::UserAgent response

Vorheriges Thema: mech and javascript modifying form post action
Nächstes Thema: RE: [Crypt::SSLeay] Compile problems on Solaris - Resolved