SOAP::Lite POD::WSDL and .NET clients
am 25.04.2007 18:41:15 von Ian WilsonIs it possible to use POD::WSDL to generate WSDL for a SOAP::Lite
service, such that the generated WSDL can be used to construct a .NET
client?
A couple of things worry me ...
(Apart form RPC/Encoded vs Doc/Literal and SOAPAction tweaking)
1) The element names generated in the returned XML (c_gensym3 ...) don't
match the names mentioned in the WSDL (ArrayOfInt) - does this matter?
2) The WSDL seems to me to imply that the individual temperature
elements ought to be wrapped in an "ArrayOfInt" element (which I could
produce by returning an array ref instead of an array: `return
\@temperatures;`) - Is the WSDL wrong?
Off Topic question (sorry):
I don't know C# or have a C# devkit - what would the stubs look like
that C# developers generate from this WSDL? Would it be much work to
make a simple (command line) C# client?
------ Example service -----
#!perl
use strict;
use warnings;
use SOAP::Transport::HTTP;
SOAP::Transport::HTTP::CGI
-> dispatch_to('Temperatures')
-> handle;
package Temperatures;
=begin WSDL
_RETURN @int Temperatures in three places
=cut
sub getTemperatures {
my @temperatures = (31.1, 28.2, 34.5);
return @temperatures
}
------ perl client ------
#!perl
use strict;
use warnings;
use SOAP::Lite;
use XML;
my $Temperatures = SOAP::Lite
-> uri('http://www.example.com/Temperatures')
-> proxy('http://localhost/cgi-bin/Temperatures.pl')
-> on_fault(sub { my($soap, $res) = @_;
die ref $res ? $res->faultstring : $soap->transport->status, "\n";
});
my @temperatures = $Temperatures->getTemperatures()->paramsall;
print join(', ', @temperatures), "\n";
my $xml = $Temperatures->outputxml(1)->getTemperatures();
XML::print_indented($xml);
------ XML.pm -----
package XML;
sub print_indented {
my $xml = shift;
$xml =~ s/>>\n
my @lines = split(/\n/, $xml);
my $indent = 0;
for my $line(@lines) {
if ($line =~ m(^)) { $indent-- }
print ' ' x $indent, $line, "\n";
if ($line =~ m(^<[^/\?])) { $indent++; }
if ($line =~ m(>[^<]+)) { $indent--; }
}
}
1;
------ output from Perl client ------
31.1, 28.2, 34.5
OAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schem
as.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" SOAP
-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding /">
------ example WSDL generated by POD::WSDL ------
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns1="http://localhost/Temperatures">
namespace="http://localhost/Temperatures" use="encoded" />
namespace="http://localhost/Temperatures" use="encoded" />
------------------------------------------------