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


In reply to Re: Calling .NET based service using SOAP::Lite for Perl by erroneousBollock
in thread Calling .NET based service using SOAP::Lite for Perl by Khurrum

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.