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

Question using .NET wsdl file in perl client

Expand Messages
  • obc_spike
    I m calling this service to test using a wsdl file in a perl client: #!/usr/bin/perl -w use strict; use SOAP::Lite +trace = debug , service =
    Message 1 of 6 , May 4, 2005
    • 0 Attachment
      I'm calling this service to test using a wsdl file in a perl client:

      #!/usr/bin/perl -w


      use strict;
      use SOAP::Lite +trace => "debug",
      service =>
      'http://www.francisshanahan.com/TheHolyBible.asmx?wsdl';


      my $soap = ListBooks()->valueof("//BookTitle");


      print "$soap\n";

      The debug trace shows the call being made (and the data coming back),
      but the print statement gives an "unblessed reference" error.

      Using this prints out the hash ID, so I know the object is stored:

      my $soap = ListBooks();

      print "$soap\n";

      How do I bless this object to get at its data? I'm not a perl
      sophisticate, so there could be something obvious I'm missing.

      Matthew
    • obc_spike
      After tinkering a bit with my perl client connecting to a .NET server, I have this: #!/usr/bin/perl -w use strict; use SOAP::Lite +trace= debug ; my $soap =
      Message 2 of 6 , May 4, 2005
      • 0 Attachment
        After tinkering a bit with my perl client connecting to a .NET server, I have this:

        #!/usr/bin/perl -w

        use strict;
        use SOAP::Lite +trace=>'debug';

        my $soap = SOAP::Lite
        ->service('http://www.francisshanahan.com/TheHolyBible.asmx?wsdl')
        ->ListBooks();

        bless $soap, "SOAP::SOM";

        for ($soap->valueof("//bible_content")) {
        print $_->BookTitle, ' - ', $_->Book, "\n";
        }

        Examining the trace output shows the data is being passed back to $soap and the bless
        statement allows me to use valueof. However, the print statement shows nothing. It
        outputs one empty line and that's it. Any idea why I'm not getting to the data in $soap?

        Matthew
      • Duncan Cameron
        ... $soap and the bless ... nothing. It ... the data in $soap? ... See this prior thread about using WSDL and getting the SOM object
        Message 3 of 6 , May 5, 2005
        • 0 Attachment
          At 2005-05-05, 06:14:12 you wrote:

          >After tinkering a bit with my perl client connecting to a .NET server,
          I have this:
          >
          >#!/usr/bin/perl -w
          >
          >use strict;
          >use SOAP::Lite +trace=>'debug';
          >
          >my $soap = SOAP::Lite
          > ->service('http://www.francisshanahan.com/TheHolyBible.asmx?wsdl')
          > ->ListBooks();
          >
          >bless $soap, "SOAP::SOM";
          >
          >for ($soap->valueof("//bible_content")) {
          > print $_->BookTitle, ' - ', $_->Book, "\n";
          >}
          >
          >Examining the trace output shows the data is being passed back to
          $soap and the bless
          >statement allows me to use valueof. However, the print statement shows
          nothing. It
          >outputs one empty line and that's it. Any idea why I'm not getting to
          the data in $soap?
          >
          >Matthew
          >
          See this prior thread about using WSDL and getting the SOM object

          http://groups.yahoo.com/group/soaplite/message/4445

          Duncan









          ___________________________________________________________
          Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com
        • obc_spike
          ... 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
          Message 4 of 6 , May 5, 2005
          • 0 Attachment
            > 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
          • 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 5 of 6 , May 5, 2005
            • 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 6 of 6 , May 5, 2005
              • 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.