CorvettePower.COM
12Nov/04

SOAP::Lite client talking to a IIS .NET Web Service

After about 4 hours of messing with different ways to get SOAP::Lite to work with a Microsoft IIS .NET Web Service, we finally found the following sample that made everything work. All attempt to try and do this in one line of code failed. This method also works with the current release of SOAP::Lite and doesn't require the beta version. Every other way we used to call the WebService resulted in us getting a blank variable passed into the WebService, rather than the value we were hoping for. You can get get SOAP::Lite from CPAN. This has been a great way for us to integrate our Unix/Linux tools with new systems we are developing on Windows.

#!/usr/bin/perl
use SOAP::Lite;
my $soap = SOAP::Lite
->uri('http://tempuri.org')
->on_action(sub{sprintf '%s%s', @_ })
->proxy('https://www.example.com/whatever/script.asmx');
my $method = SOAP::Data->name('MethodNameHere')
->attr({xmlns => 'http://tempuri.org/'});
my @params = (
              SOAP::Data->name(PARAMA => "123456789"),
              SOAP::Data->name(PARAMB => "SOMEVALUEHERE"),
              SOAP::Data->name(PARAMC => $DateString),
              SOAP::Data->name(PARAMD => "ABC")
            );
print $soap->call($method => @params) -> result;


The code we actually used

#!/local/mnt/perl/bin/perl -w 
# -- SOAP::Lite -- guide.soaplite.com --  
use SOAP::Lite; 
my $soap =  SOAP::Lite
    -> uri('http://tempuri.org/')
    -> proxy('http://natestconf01.natest.qualcomm.com/wsVacation/wsVacation.asmx')
    -> on_action(sub{sprintf '%s%s', @_ }); 
my $method = SOAP::Data->name('IsOnVacation')->attr({xmlns => 'http://tempuri.org/'}); 
my @params = (
        SOAP::Data->name(strUsername => "testuser40")
        ); 
print $soap->call($method => @params) -> result;

Web Site that I got the solution from


This wasn't on the SOAP::Lite web site, or Microsofts Interoperability Docs.

Trackbacks are disabled.