priya10 has asked for the wisdom of the Perl Monks concerning the following question:

I tried calling a .NET web service from perl scripts..And this is my code:
#!/usr/bin/perl -w # hw_client.pl - Hello client use warnings; use SOAP::Lite; my $name = shift; print "\n\nCalling the SOAP Server to say hello\n\n"; print "The SOAP Server says: "; print SOAP::Lite -> uri('urn:Example1') -> on_action(sub{sprintf '%s/%s', @_ }) -> proxy('http://localhost/HelloWorld.asmx') -> sayHello(SOAP::Data->name(name => $name)->type->('string') -> uri('urn:Example1')) -> result . "\n\n";

gives me this error message

Use of uninitialized value in subroutine entry at hello_client.pl line 11. Undefined subroutine &main:: called at hello_client .pl line 11 Please help me!!!

Replies are listed 'Best First'.
Re: Calling a .NET web service from perl scripts
by Khen1950fx (Canon) on Mar 15, 2011 at 21:05 UTC
    I made a few adjustments. I tried to stay close to your script, but note that you will need to look deeper at Microsoft's documentation.
    #!/usr/bin/perl use strict; use warnings; use SOAP::Lite (+trace => 'all', maptype => {}); my $soap = SOAP::Lite -> uri('urn:Example1') -> on_action(sub{sprintf '%s/%s', @_ }) -> proxy('http://localhost/HelloWorld.asmx') -> sayHello(SOAP::Data->type('string')->name('name')); print $soap->sayHello()->result;
Re: Calling a .NET web service from perl scripts
by SuicideJunkie (Vicar) on Mar 15, 2011 at 20:59 UTC

    You need to break up that huge chain of ->s, check the return values on those calls, and print a sensible error message when it goes wrong.

    One of those steps in the chain is either failing or not returning what you expect, but you've made your code blunder on blindly trying to use an undefined value instead of the object you need.