#71 WSDL Generated Functions do not return SOAP::SOM objects

0.65
closed-fixed
Byrne Reese
5
2007-10-05
2005-02-22
Ryan Troll
No

According to the documentation, I believe methods are
supposed to return SOAP::SOM objects. This can be seen
by looking at the section titled:

"IN/OUT, OUT PARAMTERS AND AUTOBINDING"

and/or searching for the use of the method "->result".

At this time, methods generated via WSDLs return parts
of the results, and not the SOAP::SOM object. See
SOAP/Lite.pm:2952.

Example: Consider the wsdl:

http://ws1.api.re2.yahoo.com/ws/soap-demo/full.wsdl

This wsdl defines a method ("dateInfo"), which accepts
a dateTime identifier, and returns two items: a string
(dateString), and an integer (dateSeconds). What
should to code look like to call this function, and:

* Determine whether or not an error occured; and
* Examine both results?

If a SOAP::SOM was returned, the following code snippet
would work:

my $soap = SOAP::Lite->service( $wsdl );
my $som = $soap->dateInfo( time() );

if ($som->fault)
{
print "FAULT:
[".$som->fault->faultstring."]\n";
exit(0);
}
my @r = $som->paramsall;
print "DateString: [".$r[0]."] \n";
print "DateSeconds: [".$r[1]."]\n";
}

With the existing implementation, it is possible to
fetch all of the results, but not fetch the fault if
there is a problem:

my $soap = SOAP::Lite->service( $wsdl );
my @r = $soap->dateInfo( time() );
print "DateString: [".$r[0]."] \n";
print "DateSeconds: [".$r[1]."]\n";

Maybe I'm missing something, but it looks like this
should return a SOAP::SOM object, which could be used
to determine whether or not a fault occured.

Discussion

  • Ryan Troll
    Ryan Troll
    2005-02-22

    Logged In: YES
    user_id=569674

    The attached file (full_client_dynamic.pl) demonstrates how
    to get the results using both a SOAP::SOM based response,
    and the current implementation. While there is a way to
    determine whether or not there is an error in the
    non-SOAP::SOM based response, this usage does not appear to
    mimic the non-WSDL based approach.

    This example also contains (commented out) examples that
    apparently should work, based on the documentation and/or
    example, none of which actually work.

    I do not know how to, with SOAP::SOM _or_ raw result
    responses (the default today), have the response return a
    hash containing the appropriate values. (As seen in the
    google.pl example.)

     
  • Ryan Troll
    Ryan Troll
    2005-02-22

    Example client

     
  • Byrne Reese
    Byrne Reese
    2005-03-30

    Logged In: YES
    user_id=28043

    Services generated by stubmaker.pl and generate stub now
    support a subroutine called "want_som(boolean)." When
    want_som is set to 1 or true, then the SOAP::SOM object is
    returned as opposed to the result.

     
  • Byrne Reese
    Byrne Reese
    2005-03-30

    • status: open --> open-fixed
     
  • Logged In: YES
    user_id=744645

    "With the existing implementation, it is possible to
    fetch all of the results"
    Not for me. My WSDL defines a function that returns three
    things: int, string, array of strings. when i use SOAP::Lite with
    the WSDL, the return value of the function call is only _one_ of
    those three things (whatever came first in the response XML). in
    my case the array came back first, thus the return value of the
    soap call is just an array.

    Here is an example response:

    <SOAP-ENV:Body>
    <soap_listTasksResponse SOAP-ENC:root="1">
    <task_ids SOAP-ENC:arrayType="xsd:int[8]"
    xsi:type="SOAP-ENC:Array">
    <item>586</item>
    <item>588</item>
    </task_ids>
    <errcode xsi:type="xsd:int">0</errcode>
    <errmsg xsi:type="xsd:string">success</errmsg>
    </soap_listTasksResponse>
    </SOAP-ENV:Body>

    example SOAP::Lite usage:

    $som = SOAP::Lite->service(...)->soap_listTasks();
    print Dumper($som);

    example output:

    $VAR1 = [
    '586',
    '588',
    ];

    Thanks for listening.

     
  • Martin Kutter
    Martin Kutter
    2007-10-05

    • status: open-fixed --> closed-fixed
     
  • Martin Kutter
    Martin Kutter
    2007-10-05

    Logged In: YES
    user_id=884175
    Originator: NO

    Already fixed by Byrne.

     
  • Martin Kutter
    Martin Kutter
    2007-10-05

    Logged In: YES
    user_id=884175
    Originator: NO

    Already fixed by Byrne.

     
  • gireesh kumar
    gireesh kumar
    2009-07-13

    Hi all ,

    Am also facing the same problem with my WSDL implementation. I pass all the required login credentials to the server side where I check it with the existing user information. If the user is not existing,the script dies with an error description. But with my WSDL implementation I am unable to get the fault message.

    The client side code looks like this.

    my $soap = SOAP::Lite->service('http:/IP/demo.wsdl');

    if($soap->call->fault)
    {
    print "Err",$soap->call->faultstring;
    exit;
    }
    else
    {
    print $result;
    }

    when I use this code am getting an error "Can't find method element in the message at /usr/local/share/perl/5.8.8/SOAP/Lite.pm line 2724.". The particular line at the soap::Lite states that

    die "Can't find method element in the message"
    unless $request->match($som->method);

    Is it means I can call fault function only on SOAP::SOM Object or am I doing something wrong.?Please help me.