Loading ...
Sorry, an error occurred while loading the content.

1086Re: [soaplite] SOAP call syntax

Expand Messages
  • Paul Kulchenko
    Dec 10, 2001
    • 0 Attachment
      Hi, Lon!

      you're right, service-based call will return result, so you don't
      need to call result() method.

      > 5 $response = new SOAP::Lite
      > 6 -> service($ACMEwsdl)
      > 7 -> getBalance($param1,$param2);

      In this case $response already has the result of the call. If you
      pass an escaped XML fragment you need to parse it separately.

      > Also (if I may ask one more): If I wanted to parse the return
      > strings into a hash like
      >
      > %response = (ACCOUNT=>'998091',
      > TIMESTAMP=>'1001092811',
      > BALANCE=>'214');
      >
      > couldn't I just use:
      >
      > %response = (ACCOUNT=>($response->valueof('//ACCOUNT')),
      > TIMESTAMP=>($response->valueof('//TIMESTAMP')),
      > BALANCE=>($response->valueof('//BALANCE')));

      yes, you can but you don't need to do that.

      %response = %{$response->valueof('//GETBALANCERESP')};

      will do that. BUT, GETBALANCERESP must be included as an XML
      fragment, not as an escaped XML.

      Compare:

      1. <a><b>1</b></a>
      If you get value of <a> it'll be string '<b>1</b>'

      2. <a><b>1</b></a>
      If you get value of <a> it'll be (in most cases) hash {b => 1}

      That's exactly what happens in your case. You pass XML as a string,
      and you need to parse it to get values from there. Hope it clarifies
      things a bit.

      Best wishes, Paul.

      --- kowalski <kowalski@...> wrote:
      >
      > I am attempting to call my SOAP server ACME (implemented in Java &
      > published via WSDL) using SOAP::Lite. The name of the method I
      > would
      > like to invoke is getBalance. It takes two parameters.
      >
      > So I have this:
      >
      > acmeclient.pl
      > -------------
      > 1 use SOAP::Lite;
      > 2
      > 3 (blah blah blah, define $ACMEwsdl, $param1 and $param2)
      > 4
      > 5 $response = new SOAP::Lite
      > 6 �-> service($ACMEwsdl)
      > 7 � -> getBalance($param1,$param2);
      > 8 print $response->result;
      >
      >
      > This gives me the error
      >
      > Can't call method "result" on an undefined value at acmeclient
      > line 8
      >
      > Now, I think $response is being defined because when I make the
      > following changes to lines 5-7 and comment out 8 as so:
      >
      > 5 print new SOAP::Lite
      > 6 �-> service($ACMEwsdl)
      > 7 � -> getBalance($param1,$param2);
      > 8 # print $response->result;
      >
      > I see my XML string from the ACME server printed at console.
      >
      > <?xml version="1.0"?>
      > <GETBALANCERESP><ACCOUNT>998091</ACCOUNT>
      > <TIMESTAMP>1001092811</TIMESTAMP><BALANCE
      > >214</BALANCE></GETBALANCERESP>
      >
      > I know I am doing something wrong, but I can't figure out what.
      >
      > Also (if I may ask one more): If I wanted to parse the return
      > strings
      > into a hash like
      >
      > %response = (ACCOUNT=>'998091',
      > TIMESTAMP=>'1001092811',
      > BALANCE=>'214');
      >
      > couldn't I just use:
      >
      > %response = (ACCOUNT=>($response->valueof('//ACCOUNT')),
      > TIMESTAMP=>($response->valueof('//TIMESTAMP')),
      > BALANCE=>($response->valueof('//BALANCE')));
      >
      >
      > This seems like the thing to do based on the SOAP::SOM section of
      > your help file, but I'm not sure if I need to do some intermediate
      > step first.
      >
      > Thanks so much for your help (and your excellent SOAP module).
      >
      >
      >
      > Lon Miller
      >
      >
      >
      >
      > ------------------------ Yahoo! Groups Sponsor
      >
      > To unsubscribe from this group, send an email to:
      > soaplite-unsubscribe@yahoogroups.com
      >
      >
      >
      > Your use of Yahoo! Groups is subject to
      > http://docs.yahoo.com/info/terms/
      >
      >


      __________________________________________________
      Do You Yahoo!?
      Send your FREE holiday greetings online!
      http://greetings.yahoo.com
    • Show all 3 messages in this topic