|
Posted by Ian Wilson on April 25, 2007, 12:41 pm
Please log in for more thread options
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
\@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</g;
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
<?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>
------------------------------------------------
|
| Similar Threads | Posted | | SOAP::Lite WSDL method with multiple soap:body parts | February 16, 2005, 3:32 pm |
| SOAP::Lite and WSDL namespace - please help | November 4, 2005, 10:43 am |
| SOAP::Lite and .wsdl files | April 7, 2006, 11:36 am |
| How to generate WSDL file from SOAP::Lite | May 25, 2007, 5:48 am |
| SOAP::Lite : Problem of # sign added by SOAP::Lite in the sent SOAPActionstring | November 5, 2004, 8:45 pm |
| RFC: SOAP module with implicit WSDL generation | April 4, 2008, 2:38 pm |
| SOAP::WSDL error accessing remote site. | July 19, 2007, 3:14 am |
| Writing a HTML/ASP SOAP client for a SOAP::Lite destination | March 16, 2005, 5:19 pm |
| Help with SOAP::Lite | January 19, 2005, 11:35 pm |
| SOAP::Lite | March 3, 2005, 6:13 am |
|