Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

SOAP::Lite complex types

by andreas1234567 (Vicar)
on Jun 06, 2016 at 05:56 UTC ( #1164945=perlquestion: print w/replies, xml ) Need Help??
andreas1234567 has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I am tasked to write a web services client using SOAP::Lite to access a server serving toll road passage information. It seems I cannot quite understand how to construct the complex types in perl. With SOAPUI I can successfully access on particular function of the service using a request as follows (username and password intentionally removed):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:no="no.csautopass.ws"> <soapenv:Header/> <soapenv:Body> <no:GetAllPassagesRequest> <no:userName>XX</no:userName> <no:password>YY</no:password> <no:systemActorID>23</no:systemActorID> <no:fromDate>2016-06-05T09:00:00</no:fromDate> </no:GetAllPassagesRequest> </soapenv:Body> </soapenv:Envelope>
I have not succeeded in creating a perl equivalent, this is my latest unsuccesful attempt. What should a GetAllPassagesRequest look like?
use strict; use warnings; use SOAP::Lite; use Data::Dumper; use v5.10; my $user = 'XX'; my $pass = 'YY'; my $systemActorID = 23; my $fromDate = "2016-06-06T09:00:00"; my $uri = 'https://ws.csautopass.no/services/CSNWService'; my $wsdl = $uri . '?wsdl'; my $som; my $soap = SOAP::Lite ->uri($uri) ->proxy($wsdl); my $elem1 = SOAP::Data->name('userName' => $user)->prefix('no'); my $elem2 = SOAP::Data->name('password' => $pass)->prefix('no'); my $elem3 = SOAP::Data->name('systemActorID' => $systemActorID)->prefi +x('no'); my $elem4 = SOAP::Data->name('fromDate' => $fromDate)->prefix('no'); my $elems = SOAP::Data->name("GetAllPassagesRequest" => ($elem1, $elem +2, $elem3, $elem4))->prefix('no'); eval { $som = $soap->testConnection(); ($som->result) ? say "test ok ": say "failure"; $som = $soap->getAllPassages( $elems ); ($som->result) ? say "getAllPassages call ok ": say "getAllPassage +s call failure"; say("getAllPassages paramsout:" . Dumper($som->paramsout)); if($som->fault) { say $som->faultcode . ", ". $som->faultstring; +} }; if ($@) { die $@; } __END__ C:\test\perl\soap-lite>perl test-2.pl test ok getAllPassages call failure getAllPassages paramsout: soapenv:Server, com.ctc.wstx.exc.WstxParsingException: Undeclared name +space prefix "no" at [row,col {unknown-source}]: [1,441] C:\test\perl\soap-lite>
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

Replies are listed 'Best First'.
Re: SOAP::Lite complex types
by Anonymous Monk on Jun 06, 2016 at 06:41 UTC
    Add
    use SOAP::Lite +trace => 'debug', readable => 1;
    and *see* what you get, what I get when I make some changes is this

    That seems to be almost 99% of what you're looking for

    Also, ?wsdl is a strange url for ->proxy, usually that goes with ->proxy

Re: SOAP::Lite complex types
by Mr. Muskrat (Canon) on Jun 07, 2016 at 21:05 UTC

    The SOAP error seems important to me:

    soapenv:Server, com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "no"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2018-10-22 05:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (119 votes). Check out past polls.

    Notices?