My fellow Monks,

After a few tries I'm able to communicate correctly with a webservice here at work. The following code works:
#!/usr/bin/perl use strict; use warnings; use Readonly; use SOAP::Lite +trace => "debug"; use Data::Dumper; Readonly my $SOAPURL => 'http://the.webservice/service/pers?wsdl'; my $service = SOAP::Lite->service($SOAPURL); my $payload = SOAP::Data->name( 'persKeyParam' => '123456' ); my $info = $service->getEmpInfo( '', $payload ); print Data::Dumper->new( [$info], [qw/$info/] )->Indent(1)->Dump;
How come I have to use the following:
my $info = $service->getEmpInfo( '', $payload );
The examples found in the documentation always speak of:
my $info = $service->getEmpInfo( $payload );
The code just above returns a $info = undef;

I found out about the '' by accident :)

The http://the.webservice/service/pers?wsdl returns:
<xs:complexType name='getEmpInfo'> <xs:sequence> <xs:element minOccurs='0' name='persKeyParam' type='xs:string'/> </xs:sequence> </xs:complexType>
and
<operation name='getEmpInfo'> <soap:operation soapAction=''/> <input> <soap:body use='literal'/> </input> <output> <soap:body use='literal'/> </output> </operation>
Calling $service->getEmpInfo( $payload ); with debug on gives:
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://webservice.my. +work/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <tns:getEmpInfo> <getEmpInfo xsi:nil="true" xsi:type="tns:getEmpInfo" /> </tns:getEmpInfo> </soap:Body> </soap:Envelope>
Calling $service->getEmpInfo( '', $payload ); with debug on gives:
<?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/enc +oding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns: +soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://webservice.my. +work/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <soap:Body> <tns:getEmpInfo> <getEmpInfo xsi:nil="true" xsi:type="tns:getEmpInfo" /> <persKeyParam xsi:type="xsd:int"> 123456 </persKeyParam> </tns:getEmpInfo> </soap:Body> </soap:Envelope>
The SOAP::Lite I'm using is 0.710.10

The extra '' parameter seems wrong. Why do I need to shift my persKeyParam up one index? What's going on?
For as long as $payload comes as a second parameter the call works. No matter what I put as a first param it works. I can put '' as an empty string, or a 0 or any other number.

Why does it work? If anyone could enlighten me I'd be grateful.


Greetings!
--
if ( 1 ) { $postman->ring() for (1..2); }

In reply to SOAP::Lite, I don't get it by gargle

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.