in reply to SOAP::Deserializer problem

You process a soap response so I suppose you have a soap request object with data in $request.
You want to initialize the request as
$response = $soap->myrequest($request);

Then after applying a valueof method on return object you can access your values:

$value1 = $response->valueof('//Envelope/Body/command');
$value2 = $response->valueof('//Envelope/Body/command/message');

or you can check if the path is correct with:
if ($match = $response->match('/Envelope/Body/command')) {
$value1 = $response->valueof('//Envelope/Body/command');
Hope this helps.

Replies are listed 'Best First'.
Re^2: SOAP::Deserializer problem
by axelrose (Scribe) on Jul 29, 2007 at 11:32 UTC
    I tried this:
    my $soap = SOAP::Lite->uri($uri)->proxy( $proxyUrl, timeout => 5 ); my $method = SOAP::Data->name("command")->attr( { 'template' => 'sample', 'method' => 'execute', 'loginname' => 'me', } ); my $som = $soap->call($method); if ( $som->fault ) { die $som->fault->faultstring } print $som->valueof('/Envelop/Body/command');
    and then in a debugging session:
    DB<1> x $som->valueof('/Envelope/Body/command') 0 HASH(0x1bb793c) 'message' => HASH(0x1bb793c) -> REUSED_ADDRESS DB<2> x $som->valueof('/Envelope/Body/command/message') 0 HASH(0x1bb793c) 'message' => HASH(0x1bb793c) -> REUSED_ADDRESS
    I cannot see how to access the subnodes ... Thanks for any help! Axel.
      I didn't realise you don't code the request like this:
      $method = SOAP::Data->name('command'=>'value');

      So to access attribute values you should use

      $attr_value = $som->dataof('//Envelope/Body/command')->attr->{'template'};
      $attr_value = $som->dataof('//command')->attr->{'template'};
      (I don't remember which one because don't use attributes.)

      This should hold for
      <command template="foo">100</command>

      and $attr_value is foo, command value is 100.

      Docs are in SOAP/SOM.pod of perl/site/lib directory.
        Sorry, my first go was more complicated than necessary. Here is a second simplified go to demonstrate my problem:
        #!/usr/bin/perl use warnings; use strict; use SOAP::Lite; my $xml = <<'eof'; <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=" +elope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <command id="1"> <message id="2"> <time time="27.07.2007-10:37:49 +0200"/> </message> </command> </SOAP-ENV:Body> </SOAP-ENV:Envelope> eof my $som = SOAP::Deserializer->deserialize($xml); print "time = ", $som->dataof('//command/message/time')->attr->{time}, + "\n"; print "done.\n";
        Output is
        time = 27.07.2007-10:37:49 +0200 done.
        Can't call method "attr" on an undefined value at + line 23.
        as soon as the id attributes of command and message are identical. I wouldn't care if I could get the raw XML from the SOAP response. Axel.