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

SOAP call syntax

Expand Messages
  • kowalski
    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
    Message 1 of 3 , Dec 10, 2001
    • 0 Attachment
      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
    • Paul Kulchenko
      Hi, Lon! you re right, service-based call will return result, so you don t need to call result() method. ... In this case $response already has the result of
      Message 2 of 3 , 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
      • kowalski
        Hi Paul, Thanks for the help. I got the first part of your reply, but I m so= rt of confused on the second. Is the
        Message 3 of 3 , Dec 10, 2001
        • 0 Attachment
          Hi Paul,

          Thanks for the help. I got the first part of your reply, but I'm so=
          rt of confused on the second. Is the < escaped XML? If so and my XML repl=
          y packet is

          $response = '<?xml version="1.0"?>
          <GETBALANCERESP><ACCOUNT>998091</ACCOUNT><TIMESTAMP>1001092811&=
          lt;/TIMESTAMP><BALANCE>214</BALANCE></GETBALANCERESP>';

          Then do I need to do a search and replace on $response to make all the =
          < into < before I can call valueof?

          Something like

          acmeparse.pl
          ------------
          1 (assume $response is defined here)
          2 $response =~ /s//</<//g;
          3 %response = %{$response->valueof('//GETBALANCERESP')};


          I'm just asking about the process, I know the regex is wrong. I'm still=
          new on that syntax.

          Thanks!






          --- In soaplite@y..., Paul Kulchenko <paulclinger@y...> wrote:
          > 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@y...> 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@y...
          > >
          > >
          > >
          > > 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
        Your message has been successfully submitted and would be delivered to recipients shortly.