Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-26 01:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found