perlquestion
andreas1234567
Dear Monks,<br>
I am tasked to write a web services client using [mod://SOAP::Lite] to access a server serving [href://https://ws.csautopass.no/services/CSNWService?wsdl|toll road passage information]. It seems I cannot quite understand how to construct the [href://http://www.soaplite.com/complex_types/|complex types] in perl. With [href://https://www.soapui.org/|SOAPUI] I can successfully access on particular function of the service using a request as follows (username and password intentionally removed):
<code>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 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>
</code>
I have not succeeded in creating a perl equivalent, this is my latest unsuccesful attempt. What should a <c>GetAllPassagesRequest</c> look like?
<readmore>
<code>
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)->prefix('no');
my $elem4 = SOAP::Data->name('fromDate' => $fromDate)->prefix('no');
my $elems = SOAP::Data->name("GetAllPassagesRequest" => ($elem1, $elem2, $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 "getAllPassages 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 namespace prefix "no"
at [row,col {unknown-source}]: [1,441]
C:\test\perl\soap-lite>
</code>
</readmore>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-321512">
<small>
--<br>
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. <a href="http://www.despair.com/viewall.html">[1]</a>
</small>
</div></div>