soapclient 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /usr/bin/perl
  2. ################################################################################
  3. #
  4. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems(R).
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #################################################################################
  18. use strict;
  19. use warnings;
  20. use Config::Simple qw();
  21. use SOAP::Lite qw();
  22. use Data::Dumper;
  23. my ($proxypath, $myname);
  24. BEGIN
  25. {
  26. my $cfgfile = 'soapclient.ini';
  27. my $cfg = new Config::Simple();
  28. $cfg->read($cfgfile) or die("Could not read config file $cfgfile: $!");
  29. $proxypath = $cfg->param('proxypath') or die("No proxypath in config file $cfgfile");
  30. $myname = $cfg->param('myname') or die("No myname in config file $cfgfile");
  31. }
  32. my @proxies = qw(log dispatch);
  33. my $usage = 'usage: soapclient ' . join('|', @proxies);
  34. die($usage) unless(@ARGV == 1);
  35. my ($proxyname) = @ARGV;
  36. die($usage) unless(grep({$proxyname eq $_} @proxies));
  37. my $serviceuri = 'urn:TestSOAP/TestService';
  38. my $proxyurl = $proxypath . 'soap' . $proxyname . '.cgi';
  39. my $soap = SOAP::Lite->uri($serviceuri)->proxy($proxyurl);
  40. my $arg = SOAP::Data->name('name')->type('string')->value($myname);
  41. my $resp = $soap->greeting($arg);
  42. if($resp->fault())
  43. {
  44. print('SOAP returned error ', $resp->faultcode(), ': ', $resp->faultstring(), "\n", $resp->faultdetail(), "\n");
  45. }
  46. else
  47. {
  48. print("SOAP returned OK\n");
  49. print(Data::Dumper->Dump([$resp->method()], ['SOAP_response']));
  50. }