http://www.perlmonks.org?node_id=649137


in reply to Calling .NET based service using SOAP::Lite for Perl

Don't bother hand-constructing complex types using SOAP::Data.

Instead use SOAP::WSDL (a subclass of SOAP::Lite) to talk to the web-service. It reads the service's WSDL and constructs a proxy object whose methods are able to marshal pure-perl datastructures to and from the web-service.

It's otherwise like SOAP::Lite so you can skip straight to the 'USAGE' section of the documentation.

As with SOAP::Lite (and not mentioned in SOAP::WSDL's docs) you can use $proxy->method(...) instead of $proxy->call('method'...)

Updated:

I don't know the specifics of your complexTypes, but you can use something like the following code. Also you likely don't need to specify namespaces as that should be dealt with by SOAP::WSDL.

use SOAP::WSDL; use Data::Dumper; use strict; my $soap = SOAP::WSDL->new(); $soap->wsdl('http://server/path/to.wsdl'); $soap->on_action(sub { return $_[0].$_[1]; }); # I find this he +lps with .NET services. $soap->proxy('http://server/path/to/service.asmx'); # For speed: not + necessary as SOAP::WSDL can find it in the WSDL. $soap->wsdlinit(caching => 1); my $som = $soap->SampleTest({ Name => 'Nathan', Age => 22}); if ($som->fault) { print "SampleTest Error: ".$som->faultstring."\n"; } else { print Dumper($som->paramsall); }
Note that the arguments to the method are determined positionally, and that you needn't construct a real Tester object (although if the Tester object you pass is a blessed hash, it doesn't hurt).

Also, please remember to use <code>...</code> tags when you post code so that it's easier for your fellow monks to read your post.

-David

Replies are listed 'Best First'.
Re^2: Calling .NET based service using SOAP::Lite for Perl
by Khurrum (Novice) on Nov 06, 2007 at 06:48 UTC
    Which version of SOAP::WSDL are you running. I just downloaded 2.00_23 from CPAN but having troubles installing it. I remember i tried it before but no luck. I use the following commands:

    perl Makefile.pl
    make
    make test
    make intall

    During make test some of the test cases are skipped and it complains about the client. Then when i use the Perl script it complains that it cant find the Perl Module WSDL.pm so i manually copied and pasted the perl module in the lib folder for Perl. That seems to solve that problem and then it starts complaining about not finding the perl module Client.pm now i suppose this is same reason "make test" didnt completely pass. Can i install the package somehow other so i dont have to manually find modules and place them in folders? Could you guide me on what i should do?

    Really appreciate your help.
      Which version of SOAP::WSDL are you running.
      My current codebase uses SOAP::WSDL 1.25. That's the version that will install if you issue install SOAP::WSDL from CPAN.

      I've not really used version 2. I'm sure Martin will move the CPAN linkage to version 2 when he feels it's ready.

      During make test some of the test cases are skipped and it complains about the client. Then when i use the Perl script it complains that it cant find the Perl Module WSDL.pm
      You should probably file a bug against v2 here.

      i manually copied and pasted the perl module in the lib folder for Perl. That seems to solve that problem and then it starts complaining about not finding the perl module Client.pm
      That's not a good idea. Sounds like Makefile.PL is broken.

      Can i install the package somehow other so i dont have to manually find modules and place them in folders?
      No one is recommending you do those things.

      Could you guide me on what i should do?
      Use the v1 series.

      -David

      dup, please reap.
        I installed SOAP::WSDL using the CPAN command "install SOAP::WSDL" and still an error when i compile the Perl script saying that:

        Can't locate object method "on_action" via package "SOAP::WSDL" at perlMonk.pl l ine 7

        I am not entirely sure what version of the package is being used. I would assume that because i have installed so many packages the right one might not be used. Is there a way to check which version is being used? The other problem i am looking into is that i shifted from using the Command Prompt to cygwin now. So i have noticed that they use different directories for storing the Perl packages.

        This means that when i compile a script the packages being used differ, which i dont realise. Would you be able to suggest what i should do? Scrap one way completely and start fresh somehow?

        I actually have more than one copy of perl.exe how would i be able to delete all perl modules on my box start from scratch. I currently use ActivePerl and i guess i can try removing that will all the modules and then try using cygwin to install whateevr modules i need from CPAN. Is this a good idea?