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

1100Re: SOAP Call - sending XML to hash

Expand Messages
  • markbaxterus
    Dec 14, 2001
    • 0 Attachment
      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.
    • Show all 7 messages in this topic