SOAP::Lite POD::WSDL and .NET clients

Is 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
\ [at] 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 [at] int Temperatures in three places

=cut

sub getTemperatures {
my [at] temperatures = (31.1, 28.2, 34.5);
return [at] 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) = [at] _;
die ref $res ? $res->faultstring : $soap->transport->status, "\n";
});

my [at] temperatures = $Temperatures->getTemperatures()->paramsall;
print join(', ', [at] 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</g;

my [at] lines = split(/\n/, $xml);

my $indent = 0;
for my $line( [at] 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
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:S
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 /">
<SOAP-ENV:Body>
<namesp1:getTemperaturesResponse
xmlns:namesp1="http://www.example.com/Temperatures">
<s-gensym3 xsi:type="xsd:float">31.1</s-gensym3>
<s-gensym5 xsi:type="xsd:float">28.2</s-gensym5>
<s-gensym7 xsi:type="xsd:float">34.5</s-gensym7>
</namesp1:getTemperaturesResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

------ example WSDL generated by POD::WSDL ------
<?xml version="1.0" encoding="UTF-8"?>
<!-- WSDL for http://localhost/cgi-bin/Temperatures.pl created by
Pod::WSDL version: 0.04 on Wed Apr 25 17:16:12 2007 -->
<wsdl:definitions targetNamespace="http://localhost/Temperatures"
xmlns:impl="http://localhost/Temperatures"
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">

<wsdl:types>
<schema targetNamespace="http://localhost/Temperatures"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<complexType name="ArrayOfInt">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="soapenc:int[]" />
</restriction>
</complexContent>
</complexType>
</schema>
</wsdl:types>

<wsdl:message name="getTemperaturesRequest">
</wsdl:message>

<wsdl:message name="getTemperaturesResponse">
<wsdl:part name="getTemperaturesReturn" type="tns1:ArrayOfInt">
<wsdl:documentation>Temperatures in three places</wsdl:documentation>
</wsdl:part>
</wsdl:message>

<wsdl:portType name="myServiceHandler">
<wsdl:operation name="getTemperatures" parameterOrder="">
<wsdl:input message="impl:getTemperaturesRequest"
name="getTemperaturesRequest" />
<wsdl:output message="impl:getTemperaturesResponse"
name="getTemperaturesResponse" />
</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="myServiceSoapBinding" type="impl:myServiceHandler">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http" />

<wsdl:operation name="getTemperatures">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="getTemperaturesRequest">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/Temperatures" use="encoded" />
</wsdl:input>
<wsdl:output name="getTemperaturesResponse">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/Temperatures" use="encoded" />
</wsdl:output>
</wsdl:operation>

</wsdl:binding>

<wsdl:service name="myServiceHandlerService">
<wsdl:port binding="impl:myServiceSoapBinding" name="myService">
<wsdlsoap:address location="http://localhost/cgi-bin/Temperatures.pl" />
</wsdl:port>
</wsdl:service>

</wsdl:definitions>
------------------------------------------------
Ian Wilson [ Mi, 25 April 2007 18:41 ] [ ID #1697764 ]
Perl » comp.lang.perl.modules » SOAP::Lite POD::WSDL and .NET clients

Vorheriges Thema: Perl module to send mail with Attachments
Nächstes Thema: Is it possible to use a custom perl binary inside a prebuilt apache/mod_perl environment?