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

Error handling when reading WSDL

Expand Messages
  • Mark Knoop
    Hi I have a script which does something like the following (this is an example for test purposes using some public service): ### use strict; use warnings; use
    Message 1 of 1 , Mar 12, 2008
    • 0 Attachment
      Hi

      I have a script which does something like the following (this is an example
      for test purposes using some public service):
      ###
      use strict;
      use warnings;
      use SOAP::Lite;
      use Data::Dumper;
      my $service =
      SOAP::Lite->service('http://ws.cisa.ca/WehireWS/JobsWs.asmx?WSDL');
      my $result = $service->GetAll;
      print Dumper($result);
      ###

      I get the output:

      ###
      $VAR1 = {
      'JobDetail' => {
      'PostingDate' => '1/30/2006',
      'Location' => 'British Columbia',
      'Url' =>
      'http://www.wehire.ca/view.php?job_id=1408',
      'Category' => 'Construction',
      'Company' => 'XS West Construction Group',
      'Title' => 'Equipment Operator'
      }
      };
      ###

      There are occasions when the wsdl file is not available which I can fake by
      changing the wsdl URI to something silly like:

      ###
      use strict;
      use warnings;
      use SOAP::Lite;
      use Data::Dumper;
      my $service =
      SOAP::Lite->service('http://ws.cisa.xx/WehireWS/JobsWs.asmx?WSDL');
      my $result = $service->GetAll;
      print Dumper($result);
      ###

      Now I get the output:

      ###
      Service description 'http://ws.cisa.xx/WehireWS/JobsWs.asmx?WSDL' can't be
      loade
      d: 500 Can't connect to ws.cisa.xx:80 (Bad hostname 'ws.cisa.xx')
      ###

      The thing is in my real app I want to handle this scenario without it
      spitting out the error - eg to retry it a few times then if it still doesn't
      work perform my own error handling.

      Is there a 'best practice' for doing this? I'm a bit unsure of where to
      start in terms of catching this and I want to make sure I have every
      eventuality covered not just my faked bad hostname.

      I guess I also need to do this for the method calls.

      I had a look at the cookbook but couldn't find anything...

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