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.


In reply to Re^2: .net-friendly soap messages with Apache::SOAP by theblop
in thread .net-friendly soap messages with Apache::SOAP by theblop

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.