Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

SOAP::Lite, I don't get it

by gargle (Chaplain)
on Sep 17, 2010 at 12:16 UTC ( [id://860472]=perlquestion: print w/replies, xml ) Need Help??

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

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); }

Replies are listed 'Best First'.
Re: SOAP::Lite, I don't get it
by Anonymous Monk on Sep 17, 2010 at 17:16 UTC
    Why does it work? If anyone could enlighten me I'd be grateful.

    Because the SOAP server you're using decided it can do whatever it wants, even if it makes no sense

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://860472]
Approved by dHarry
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found