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

Re: SOAP Call - sending XML to hash

Expand Messages
  • kowalski
    That happens to my posts as well. I usually edit in a text editor and paste to the post window. That hint looks useful, I had read about the call function but
    Message 1 of 7 , Dec 14, 2001
    • 0 Attachment
      That happens to my posts as well. I usually edit in a text editor and paste to the post window.

      That hint looks useful, I had read about the call function but haven't worked with it. Thanks for the help, I'll give it a try and let you know.


      --- In soaplite@y..., "markbaxterus" <markbaxterus@y...> wrote:
      > BTW, Sorry about the formatting of that response. The code was
      > indented nicely in the preview window before I sent it. Not quite
      > sure why everything was scrunched to the left margin.
      >
      > Mark
      >
      > --- In soaplite@y..., "markbaxterus" <markbaxterus@y...> wrote:
      > > Hello,
      > >
      > > I'm not Paul, but I'll attempt to give a reasonable response. :-)
      > >
      > > A service/wsdl call does not return a SOAP::SOM object. Instead it
      > > returns the result directly. However, you can get at the SOAP::SOM
      > > object.
      > >
      > > Suppose that you have a method "getStuff" that you want to call, and
      > > you want to be able to use a wsdl ($wsdl will be defined) or you use
      > > uri/proxy directly to make the call.
      > >
      > > I have used code similar to the following for this:
      > >
      > > my $som;
      > > if ($wsdl) {
      > > my $soap = SOAP::Lite->service($wsdl);
      > > $soap->getStuff($request);
      > > $som = $soap->call;
      > > } else {
      > > # A uri/proxy call...
      > > my $soap = SOAP::Lite->uri($URI)->proxy($PROXY);
      > > $som = $soap->getStuff($request);
      > > }
      > >
      > > if ($som->fault) {
      > > my ($pkg, $filename, $line) = caller(0);
      > > my $from = "$filename line $line";
      > > print("FAULT($from): ", join ', ',
      > > $som->faultcode, $som->faultstring);
      > > my $detail = $som->faultdetail;
      > > print ", $detail" if $detail;
      > > print "\n";
      > > return;
      > > } else {
      > > return $som->result;
      > > }
      > > }
      > >
      > > Hope that helps.
      > >
      > > Mark
      > >
      > >
      > > --- In soaplite@y..., "kowalski" <kowalski@y...> wrote:
      > > >
      > > > Hi Paul, I'm looking for a little more information on one of the
      > > questions I asked earlier.
      > > >
      > > > I have the following client:
      > > >
      > > > 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
      > > > 9 if ($response->fault) {
      > > > 10 $response = "Fault code: ". $response->faultcode."\n" ;
      > > > 11 }
      > > > 12 else {
      > > > 13 my %response = %{$response->valueof('//GETBALANCERESP')};
      > > > 14 }
      > > > 15 if (defined (%response)) {while(($key ,$value) =
      > each(%h){print
      > > "$key => $h{$key}\n";}
      > > > 15 print "Response is \n$response";
      > > >
      > > >
      > > > I run this client, and I get
      > > >
      > > > Can't call method "valueof" without a package or object
      > reference
      > > at acmeclient.pl line 13.
      > > >
      > > > I comment out line 12-14 and I get
      > > >
      > > > Can't call method "fault" without a package or object reference at
      > > acmeclient.pl line 9.
      > > >
      > > > I comment out line 9-14 and I get
      > > >
      > > > Response is
      > > > <?xml version="1.0"?>
      > > >
      > >
      > <GETBALANCERESP><ACCOUNT>998091</ACCOUNT><TIMESTAMP>1001092811<TIMESTAMP><BALANCE>214</BALANCE></GETBALANCERESP>
      > > >
      > > > How do I get at the fault or do a valueof on what appears to be a
      > > string? Is there another library I can include? What am I doing
      > wrong,
      > > the call is returning but I can't seem to get at it.
      > > >
      > > > I feel like I'm just at the edge of understanding all of this if
      > I
      > > can just figure out how to use $response.
      > > >
      > > > As always, thanks for your help. I look forward to someday being
      > > able to help answer some questions in this forum instead of always
      > > asking them.
    • Joe Landman
      ... I wrap all my SOAP::Lite calls in an eval, and look at @_ afterwords. I think there may be other ways to do the same thing.
      Message 2 of 7 , Dec 17, 2001
      • 0 Attachment
        On Mon, 2001-12-17 at 11:51, Mental wrote:

        > The next question is: Is there a way to call service and not have it blow
        > up if the url is unreachable?
        >
        > > my $soap = SOAP::Lite->service($wsdl);
        >
        > If in this case, $wsdl is unreachable or down, you'll get an error
        > regardless of what you want to do next. I'm talking to several search

        I wrap all my SOAP::Lite calls in an eval, and look at @_ afterwords. I
        think there may be other ways to do the same thing.
      • Paul Kulchenko
        Hi, Mental! ... my $soap = eval { SOAP::Lite- service($wsdl) } || return undef; You can also check $@ after eval{} but it seems like you don t care in this
        Message 3 of 7 , Dec 17, 2001
        • 0 Attachment
          Hi, Mental!

          > server to not blowup the other calls. Thus, in
          > sub get_soap_results I'd like to do something to the effect of
          >
          > my $soap = SOAP::Lite->service($wsdl) || return undef;

          my $soap = eval { SOAP::Lite->service($wsdl) } || return undef;

          You can also check $@ after eval{} but it seems like you don't care
          in this case, so you can just return.

          Best wishes, Paul.

          --- Mental <mental@...> wrote:
          > The next question is: Is there a way to call service and not have
          > it blow
          > up if the url is unreachable?
          >
          > > my $soap = SOAP::Lite->service($wsdl);
          >
          > If in this case, $wsdl is unreachable or down, you'll get an error
          > regardless of what you want to do next. I'm talking to several
          > search
          > engines, one of which is a soap server. I'd like my call to the
          > soap
          > server to not blowup the other calls. Thus, in
          > sub get_soap_results I'd like to do something to the effect of
          >
          > my $soap = SOAP::Lite->service($wsdl) || return undef;
          >
          > The service being down isnt important (to me) so much as the
          > composite
          > results from the remaining sources are.... Should I factor out soap
          > to its
          > own object and call it from there? I think the way its handling an
          > unreachable service will bubble up regardless.
          >
          > I suppose I could validate the url with LWP first, but that seems
          > expensive for my purposes.....
          >
          >
          > Thanks for any insight.
          >
          > --
          > Mental (Mental@...)
          >
          > Are there any questions?
          > --Steven Wright
          >
          > GPG public key: http://www.neverlight.com/Mental.asc
          >
          >
          >
          > ------------------------ 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!?
          Check out Yahoo! Shopping and Yahoo! Auctions for all of
          your unique holiday gifts! Buy at http://shopping.yahoo.com
          or bid at http://auctions.yahoo.com
        • Mental
          ... Good stuff to know. :) ... The next question is: Is there a way to call service and not have it blow up if the url is unreachable? ... If in this case,
          Message 4 of 7 , Dec 17, 2001
          • 0 Attachment
            On Fri, Dec 14, 2001 at 09:31:22PM -0000, markbaxterus wrote:
            > Hello,
            >
            > I'm not Paul, but I'll attempt to give a reasonable response. :-)
            >

            Good stuff to know. :)

            > A service/wsdl call does not return a SOAP::SOM object. Instead it
            > returns the result directly. However, you can get at the SOAP::SOM
            > object.

            The next question is: Is there a way to call service and not have it blow
            up if the url is unreachable?

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

            If in this case, $wsdl is unreachable or down, you'll get an error
            regardless of what you want to do next. I'm talking to several search
            engines, one of which is a soap server. I'd like my call to the soap
            server to not blowup the other calls. Thus, in
            sub get_soap_results I'd like to do something to the effect of

            my $soap = SOAP::Lite->service($wsdl) || return undef;

            The service being down isnt important (to me) so much as the composite
            results from the remaining sources are.... Should I factor out soap to its
            own object and call it from there? I think the way its handling an
            unreachable service will bubble up regardless.

            I suppose I could validate the url with LWP first, but that seems
            expensive for my purposes.....


            Thanks for any insight.

            --
            Mental (Mental@...)

            Are there any questions?
            --Steven Wright

            GPG public key: http://www.neverlight.com/Mental.asc
          Your message has been successfully submitted and would be delivered to recipients shortly.