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

Re: [soaplite] Re: Question using .NET wsdl file in perl client

Expand Messages
  • Duncan Cameron
    ... You need to access everything through the som object. In your case it looks like the return value from Listbooks() does not give you everything that you
    Message 1 of 6 , May 5 7:33 AM
    • 0 Attachment
      At 2005-05-05, 15:13:47 you wrote:

      >> See this prior thread about using WSDL and getting the SOM object
      >>
      >> http://groups.yahoo.com/group/soaplite/message/4445
      >>
      >> Duncan
      >
      >Hi Duncan,
      >
      >Thanks for your note. I've tested the example from that thread and it
      >works fine for validating a result or fault, but I'm still unable to
      >iterate a complex object (the .NET dataset). Here's what I have now:
      >
      >#!/usr/bin/perl -w
      >use SOAP::Lite +trace=>'debug';
      >my $obj = SOAP::Lite
      > ->
      >service('http://www.francisshanahan.com/TheHolyBible.asmx?wsdl');
      >my $books = $obj->ListBooks();
      >my $som = $obj->call;
      >unless ($som->fault) {
      > print "result: ", $som->result, ' $books: ', $books, "\n";
      > for ($books->valueof('//bible_content')) {
      > print $_->BookTitle, "\n";
      > }
      >}
      >
      >This is the output:
      >
      >result: HASH(0x85a3174) $books: HASH(0x85a3174)
      >Can't call method "valueof" on unblessed reference at ./WSDLExample.pl
      >line 9.
      >
      >The output verifies the $som->result and the original returned value
      >($books) are the same HASH ref, but trying to use $books gets the
      >unblessed error. Blessing it as a SOAP::SOM object removes the error,
      >but doesn't do anything in the for loop. Is there another step I'm
      >missing?
      >
      >Matthew
      >
      You need to access everything through the som object. In your case it
      looks like the return value from Listbooks() does not give you
      everything that you want.
      Does this work for you?

      unless ($som->fault) {
      print "result: ", $som->result, ' $books: ', $books, "\n";
      for ($som->valueof('//bible_content')) {
      print $_->BookTitle, "\n";
      }
      }

      Duncan









      ___________________________________________________________
      Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com
    • obc_spike
      ... Thanks for the help. My goal was the shorter WSDL notation, but still being able to iterate individual items from the returned DataSet (i.e.,
      Message 2 of 6 , May 5 8:19 AM
      • 0 Attachment
        > You need to access everything through the som object. In your case it
        > looks like the return value from Listbooks() does not give you
        > everything that you want.

        Thanks for the help. My goal was the shorter WSDL notation, but still
        being able to iterate individual items from the returned DataSet
        (i.e., $_->BookTitle). The key was adding a deserializer. This code
        works for me:

        #!/usr/bin/perl -w
        use SOAP::Lite;
        my $obj = SOAP::Lite
        ->
        service('http://www.francisshanahan.com/TheHolyBible.asmx?wsdl')
        -> deserializer(SOAP::Custom::XML::Deserializer->new);
        my $books = $obj->ListBooks();
        my $som = $obj->call;
        unless ($som->fault) {
        for ($som->valueof('//bible_content')) {
        print $_->BookTitle, "\n";
        }
        }

        Matthew
      Your message has been successfully submitted and would be delivered to recipients shortly.