SOAP - PERFORMANCE

PERFORMANCE ^

Processing of XML encoded fragments

    SOAP::Lite is based on XML::Parser which is basically wrapper around James Clark's expat parser. Expat's behavior for parsing XML encoded string can affect processing messages that have lot of encoded entities, like XML fragments, encoded as strings. Providing low-level details, parser will call char() callback for every portion of processed stream, but individually for every processed entity or newline. It can lead to lot of calls and additional memory manager expenses even for small messages. By contrast, XML messages which are encoded as base64Binary, don't have this problem and difference in processing time can be significant. For XML encoded string that has about 20 lines and 30 tags, number of call could be about 100 instead of one for the same string encoded as base64Binary.

    Since it is parser's feature there is NO fix for this behavior (let me know if you find one), especially because you need to parse message you already got (and you cannot control content of this message), however, if your are in charge for both ends of processing you can switch encoding to base64 on sender's side. It will definitely work with SOAP::Lite and it may work with other toolkits/implementations also, but obviously I cannot guarantee that.

    If you want to encode specific string as base64, just do SOAP::Data->type(base64 => $string) either on client or on server side. If you want change behavior for specific instance of SOAP::Lite, you may subclass SOAP::Serializer, override as_string() method that is responsible for string encoding (take a look into as_base64Binary()) and specify new serializer class for your SOAP::Lite object with:

      my $soap = new SOAP::Lite
        serializer => My::Serializer->new,
        ..... other parameters

    or on server side:

      my $server = new SOAP::Transport::HTTP::Daemon # or any other server
        serializer => My::Serializer->new,
        ..... other parameters

    If you want to change this behavior for all instances of SOAP::Lite, just substitute as_string() method with as_base64Binary() somewhere in your code after use SOAP::Lite and before actual processing/sending:

      *SOAP::Serializer::as_string = \&SOAP::XMLSchema2001::Serializer::as_base64Binary;

    Be warned that last two methods will affect all strings and convert them into base64 encoded. It doesn't make any difference for SOAP::Lite, but it may make a difference for other toolkits.
 

source: http://search.cpan.org/~phred/SOAP-Lite-1.20/lib/SOAP/Lite.pm#PERFORMANCE