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

Re: [soaplite] Consuming .NET service

Expand Messages
  • Duncan Cameron
    ... What is ca? Should it be ca ? ... You don t want this. GetAuthors() returns the real result. See the examples in the SOAP::Schema section of the pod.
    Message 1 of 4 , Jun 16, 2002
      On 2002-06-16 jbpion wrote:
      >Hello all,
      >
      >I am afraid that I am new to SOAP and hope that my question has not
      >already been answered in the archives (I've looked at a lot of posts
      >to find the answer, but have yet to find a solution.)
      >
      >I am trying to write a SOAP:Lite client on Unix that will consume a
      >..NET web service.
      >
      >I have already had success creating a server and client on the Unix
      >box following the examples in the documentation and the Perl.com
      >"Getting Started" guide.
      >
      >Unfortunately, I am not having the same luck with my connection
      >attempts to .NET.
      >
      >A colleague created a simple web service that returns a dataset from a
      >demo database.
      >
      >I extracted the .wsdl file using disco.exe and moved it to the same
      >directory as my client script. According to the debug information I
      >appear to be connecting.
      >
      >The documentation makes the process of returning the result set seem
      >quite easy. However, whenever I try to invoke the result method I get
      >"Can't call method result on unblessed reference".
      >
      >If I look at the value returned directly it appears to be a hash
      >reference containing a hash of hashes, the first two keys of which are
      >diffgram and schema.
      >
      >Below are the perl script, the wsdl file, and the debug output. Any
      >help would be most appreciated.
      >
      >-Jerome Pion
      >
      >P.S. I apologize for the length of my post.
      >
      >Client script:
      >#! /usr/local/bin/perl
      >use SOAP::Lite;
      >my $s = SOAP::Lite
      > ->service('file:///perl/SOAP/dataservice.wsdl')
      > ->on_debug(sub{print @_})
      > ->GetAuthors(ca)
      > ;

      What is ca? Should it be 'ca' ?

      >print $s->result;

      You don't want this. GetAuthors() returns the real result.
      See the examples in the 'SOAP::Schema' section of the pod.
      >
      .. snipped ...

      > <diffgr:diffgram
      > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
      > xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"/>

      This is where your resultant authors would be, but there aren't any!

      >Can't call method "result" on unblessed reference at ./test8.pl line
      >16.
      Caused by $s->result;


      Regards,
      Duncan Cameron
    • jbm15260
      I m having the same problem, but it seems as though a blessed reference is returned when you use the uri and proxy methods, but not when you use the service
      Message 2 of 4 , Jun 17, 2002
        I'm having the same problem, but it seems as though a blessed
        reference is returned when you use the uri and proxy methods, but not
        when you use the service method.

        This works:

        my $result = SOAP::Lite
        -> uri("myservice")
        -> proxy("http://localhost:5125")
        -> processFile(SOAP::Data->type(base64 => $file_contents));

        if ($result->fault) {
        print "\n", $result->faultcode, " ", $result->faultstring, "\n\n";
        }
        else {
        my %resulthash = %{$result->result};
        print "\ncode: $resulthash{'code'}\n";
        print "string: $resulthash{'string'}\n\n";
        }

        But removing the uri and proxy calls and replacing them with a service
        call, as:

        -> service('http://localhost:3561/myservice.wsdl')

        Gives me the "Can't call method "fault" on unblessed reference"
        error. I don't understand why $result is a blessed reference in the
        former case but not in the latter. Is this a bug or am I missing
        something?
      • Jerome Pion
        ... Thank you for your help. After Duncan narrowed the problem for me (the service was not returning any data) I was able to come up with a solution. I tried
        Message 3 of 4 , Jun 17, 2002
          --- jbm15260 <jbm15260@...> wrote:
          > I'm having the same problem, but it seems as though
          > a blessed
          > reference is returned when you use the uri and proxy
          > methods, but not
          > when you use the service method.
          >
          > This works:
          >
          > my $result = SOAP::Lite
          > -> uri("myservice")
          > -> proxy("http://localhost:5125")
          > -> processFile(SOAP::Data->type(base64 =>
          > $file_contents));
          >
          > if ($result->fault) {
          > print "\n", $result->faultcode, " ",
          > $result->faultstring, "\n\n";
          > }
          > else {
          > my %resulthash = %{$result->result};
          > print "\ncode: $resulthash{'code'}\n";
          > print "string: $resulthash{'string'}\n\n";
          > }
          >
          > But removing the uri and proxy calls and replacing
          > them with a service
          > call, as:
          >
          > -> service('http://localhost:3561/myservice.wsdl')
          >
          > Gives me the "Can't call method "fault" on unblessed
          > reference"
          > error. I don't understand why $result is a blessed
          > reference in the
          > former case but not in the latter. Is this a bug or
          > am I missing
          > something?
          >
          >

          Thank you for your help.

          After Duncan narrowed the problem for me (the service
          was not returning any data) I was able to come up with
          a solution.

          I tried sending a post to the group, but it never
          showed up.

          The method, GetAuthors, accepts a US state
          abbreviation and returns a list of author names and
          addresses. The data is returned between <AuthorsList>
          tags.

          The solution I came up with was:
          #! /usr/local/bin/perl
          use SOAP::Lite;

          $debug =1;
          $soap = SOAP::Lite
          ->uri('http://tempuri.org/GetAuthors/')
          ->proxy('http://nt2ktest/MyService/dataservice.asmx')
          ->on_action(sub {join '', @_})
          ;

          $soap ->on_debug(sub{print @_}) if $debug;

          my $method = SOAP::Data->name('GetAuthors')
          ->attr({xmlns => 'http://tempuri.org/'});

          my @rc = $soap->call($method =>
          SOAP::Data->name('sValue' =>
          'ca'))->valueof('//AuthorsList');

          foreach $item (@rc){
          foreach $key (keys %$item){
          print $item->{$key},'|';
          }
          print "\n";
          }

          You'll notice that I'm using uri/proxy instead of
          service. If I try using ->service I get a "Transport
          is not specified" error so I am unable to test your
          theory.

          The above works for me, and I can get the information
          I need about the web service by calling the .asmx file
          from my browser. I'm going to continue playing around
          with the the service method, and with the code you
          provided.

          Thanks again,
          -Jerome Pion

          __________________________________________________
          Do You Yahoo!?
          Yahoo! - Official partner of 2002 FIFA World Cup
          http://fifaworldcup.yahoo.com
        Your message has been successfully submitted and would be delivered to recipients shortly.