|
I am no super user but as I understand SOAP::Lite has very little dependence on WSDL, ie there is no validation etc. I can only see it being used in a client to get an endpoint (the url of where to find the web service) and the names of the operations. This means that what you code in your server needs to be again hand crafted into the WSDL. That said, the WSDL is only handy for using code constructing tools to convert the WSDL into a code stub to consume the web service. These are available in Java and .NET and are very handy but I do not know of anything in PERL to do the same so again for all but the simplest of web services (ie where you just call a web service operation and get a response) you will need to hand code the client to match the WSDL and hopefully match the server. As for the "gensym" xml tags they are used whenever you do not provide a named tag using SOAP::Data. Here is an example
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope ...>
<soap:Body>
<performOperation>
<authentication>
<username>fred</username>
<password>pass</password>
<authentication>
<performOperation>
</soap:Body>
</soap:Envelope>
so you have a webservice with an operation "performOperation" that requires a username and password in an authentication tag. This would be generated as follows in a client (or server if that was the response)
return SOAP::Data->name(authentication => \SOAP::Data->value(
SOAP::Data->name(username => 'fred')->type('string'),
SOAP::Data->name(password => 'pass')->type('string'),
));
actually I lie a bit as the type directive will add an attribute to the appropriate tag along the lines of xsi:type="xsd:string". All the other things like operation name, envelope and body are handled by SOAP::Lite.
Also to read in named parameters you need to do the following
package MyWebService
# have to inherit from following to get SOAP envelope
use base qw(SOAP::Server::Parameters);
sub performOperation {
my $envelope = pop; # the SOAP::SOM object is tacked onto the end
# can get at the named parameters this way
my $authentication = $envelope->dataof('/Enveloope/Body/[1]/authentication');
# or this way
my $username = $envelope->dataof('/Enveloope/Body/[1]/authentication/username');
my $password = $envelope->dataof('/Enveloope/Body/[1]/authentication/password');
# and this is nonsensical but should be true
soSomethingNow()
if $username eq $authentication->value->{'username'}
&& $password eq $authentication->value->{'password'}
}
Ok just another note, I have not tested the code but have pretty much copied it exactly from an application I have written.
cheers Saramic
|