agentorange has asked for the wisdom of the Perl Monks concerning the following question:
Hi, hoping someone can help move me along
What am I doing wrong with the $in data? Why am I unable to receive the entire payload?
I've been playing with XML::Compile::WSDL11 the last few weeks and have got my head around a basic WSDL to define the service. No problem in building out each service but do have an issue receiving the data from the client. I'm using soapUI3.5.1 to test and the response I expect is returned fine but data at the server end isn't. I expect to receive this:
but instead I only receive this$VAR1 = { 'hostname' => 'host123' 'disk' => '500' 'cpu' => '4' 'memory' => '16' };
Key part of the code is pretty much as per the examples provided with XML::Compile$VAR1 = { 'memory' => '16' };
use warnings; use strict; my $serverhost = 'myserver.net'; my $serverport = '38383'; my $wsdl_filename = 'my.wsdl'; use XML::Compile::SOAP::Daemon::NetServer; use XML::Compile::WSDL11; use XML::Compile::SOAP11; use XML::Compile::Util qw/pack_type/; sub sendData($$$); my $daemon = XML::Compile::SOAP::Daemon::NetServer->new(); my $wsdl = XML::Compile::WSDL11->new($wsdl_filename); my %callbacks = ( sendData => \&sendData ); $daemon->operationsFromWSDL( $wsdl, callbacks => \%callbacks ); $daemon->setWsdlResponse($wsdl_filename); print "Starting daemon PID=$$ on $serverhost:$serverport\n"; $daemon->run ( name => 'NamesService', host => $serverhost, port => $serverport, # Net::Server::PreFork parameters min_servers => 1, max_servers => 1, min_spare_servers => 0, max_spare_servers => 0 ); sub sendData($$$) { my ($server, $in, $request) = @_; trace join '', 'sendData', Dumper $in; if( open OUT, '>', '/tmp/data.txt' ) { print OUT Dumper $in; print OUT Dumper $request; close OUT; } # 'return' hash matched to message part response in WSDL return +{ Return => "OK" }; }
The key part of my WSDL looks like so
Therefore sending the following payload to my server<message name="sendData"> <part name="hostname" element="xsd:string"/> <part name="disk" element="xsd:string"/> <part name="cpu" element="xsd:string"/> <part name="memory" element="xsd:string"/> </message>
should result in the follow Perl hash being output to my debug file /tmp/data.txt<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envel +ope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <soapenv:Header/> <soapenv:Body> <xs:string>host123</xs:string> <xs:string>500</xs:string> <xs:string>4</xs:string> <xs:string>16</xs:string> </soapenv:Body> </soapenv:Envelope>
It doesn't though and instead I only receive this$VAR1 = { 'hostname' => 'host123' 'disk' => '500' 'cpu' => '4' 'memory' => '16' };
Although the $request quite clearly has the data in it$VAR1 = { 'memory' => '16' };
What am I doing wrong with the $in data?$VAR1 = bless( { '_protocol' => 'HTTP/1.1', '_content' => '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlso +ap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <soapenv:Header/> <soapenv:Body> <xs:string>host123</xs:string> <xs:string>500</xs:string> <xs:string>4</xs:string> <xs:string>16</xs:string> </soapenv:Body> </soapenv:Envelope>', .. .. ..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Processing request from XML::Compile
by Anonymous Monk on Nov 01, 2013 at 01:55 UTC | |
by agentorange (Sexton) on Nov 07, 2013 at 10:24 UTC |