in reply to Re: .net-friendly soap messages with Apache::SOAP
in thread .net-friendly soap messages with Apache::SOAP

I've been trying to create a custom Serializer for my soap server, but it looks rather complicated to find a generic solution that would work with any kind of data.

Here's my (very) custom serializer:

package MySerializer; @MySerializer::ISA = 'SOAP::Serializer'; sub envelope { my $self = shift; my $type = shift; if ($type =~ /^response$/ && $_[0] eq 'CheckResponse') { $_[0] = SOAP::Data->name($_[0])->prefix(''); $_[1] = SOAP::Data->value( SOAP::Data->name(text => $_[1]->{text}), SOAP::Data->name(severity => $_[1]->{severity}), SOAP::Data->name(error => $_[1]->{error}), ); } $self->SUPER::envelope($type, @_); }
And the resulting response XML:
<?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/1999/XMLSchema-instanc +e" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:S +OAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http:/ +/www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xm +lsoap.org/soap/encoding/"> <SOAP-ENV:Body> <CheckResponse> <text xsi:type="xsd:string">Valid Domain</text> <severity xsi:type="xsd:int">0</severity> <error xsi:type="xsd:int">0</error> </CheckResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
Which is quite close to what the .net client expects.

The only problem with that solution is that the serializer has to be modified if the Check() method changes, and any other method exposed via SOAP::Lite will need a custom serializer to achieve the same compatibility.

Is it possible to write the serializer in a more generic way? I haven't found anything in all the SOAP::Lite articles I read on the web, nor in the code for SOAP::Serializer (which I found rather hard to follow!)

Cheers,
theblop.