Start by reading the first 2 parts :SOAP::Data::Builder is simply a wrapper around SOAP::Data and SOAP::Serializer for SOAP::Lite. I used it because it made my life easier building nested complicated SOAP objects. However for Part 2 I will simply be showing how to use it to do the same code as Part 1. Unfortunately since Part 1 is so Simple this actually makes SOAP::Data::Builder more complex than SOAP::Lite would be for this. In a future installment I will attempt to show more complex examples, but I will explain them less. Now let’s take a look at the code.
As you can see this is much the same as the final code in Part 1, and if you run it, it does exactly the same thing. The first difference you’ll notice is the self explanatory creation of the SOAP::Data::Builder object. After that comes the
->add_elem method call, which will simply create an element with a given element name and a value for that element.
Once you’ve finished adding elements to your
$sb object, then you can call pass
$sb->to_soap_data to the method that you’re calling on SOAP::Lite, this generates the structure that SOAP::Lite needs to be able to make your request.
The only thing I didn’t like about SOAP::Data::Builder is if you don’t pass the right parameters to
->add_elem it will not croak or error in any way that will really tell you what went wrong. Simple patches to this can fix it.