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:

$VAR1 = { 'hostname' => 'host123' 'disk' => '500' 'cpu' => '4' 'memory' => '16' };
but instead I only receive this
$VAR1 = { 'memory' => '16' };
Key part of the code is pretty much as per the examples provided with XML::Compile

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

<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>
Therefore sending the following payload to my server
<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>
should result in the follow Perl hash being output to my debug file /tmp/data.txt
$VAR1 = { 'hostname' => 'host123' 'disk' => '500' 'cpu' => '4' 'memory' => '16' };
It doesn't though and instead I only receive this
$VAR1 = { 'memory' => '16' };
Although the $request quite clearly has the data in it
$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>', .. .. ..
What am I doing wrong with the $in data?

Replies are listed 'Best First'.
Re: Processing request from XML::Compile
by Anonymous Monk on Nov 01, 2013 at 01:55 UTC

    Can you post a usable wsdl file? And a client?

    There is way too many moving parts, and the author of XML::Compile , markov, hasn't visited in years

      Shame he's not been around because this appears to be one of the best thought out modules for SOAP, XML, WSDL and XSD.

      I've gone back to the drawing board and re-written it from scratch. I often find that useful as it helps you question and understand what you previously wrote. Sometimes you can learn a lot from that.

      I have and as a result my question is slightly different. So I'll close this and perhaps open a new topic in a couple of days.