SOAP::Lite for Perl is a collection of Perl modules which provides a simple and lightweight interface to the Simple Object Access Protocol (SOAP, also known as Service Oriented Access Protocol) both on client and server side.
I discovered recently that SOAP::Lite isn't necessary well-behaved when it comes to conforming to SOAP intermediary requirements. According to the spec, SOAP services must ignore headers not addressed to them and must pass them along untouched in any response they deliver. Now most developers don't need to worry about this because this capability is only relevant to people invoking SOAP intermediaries. However, at Grand Central where I work, we use SOAP intermediaries all the time; in one scenario, we were calling a Web Service I built using Perl, but it did not persist SOAP Headers properly. So, I wrote some code to address the problem, and now it works as the SOAP specrequires.
This is a simple answer addressed in an article I wrote for Builder.com entitled A Hands On Tour of SOAP::Lite. The answer is also answered, albeit indirectly, in a previous post about complex types. The secret is properly escaping the SOAP::Data element like so: \SOAP::Data. I know, it is not very intuitive. :-(
For those with really complicated XML elements that need to have multiple namespace declarations - possibly because some out of scope XML attributes need to be declared - can rest assured that there is an easy way to do it. It is not as automatic as the traditional SOAP::Lite->uri() method, but it works just the same...
I was faced with the dilemna of having an XML document that I had scraped from a web page that I wanted to encode into a SOAP Envelope, but I couldn't figure out how to do it, so I asked the SOAP::Lite mailing list (a long time ago) and got my answer. And since several others (including this one, and this one) have asked the same question. Since the question is so popular - here is how you do it...
Last week I showed how to override the root element of a request, but did not show a way to do the same thing for the root element of a response. So, read on if you would like to know how to modify the response's namespace, namespace prefix, encoding style, etc. It is not very intuitive, or pretty for that matter, but at least it is relatively simple.
SOAP::Lite's API allows you to call remote Web service operations easily within your code. Simply instantiate an instance of a service, and execute (or call) the remote method directly from your service instance. For example, a call might look like "$soap->myMethod(arguments)." However, while this convention makes for a nice API, by calling the method in this way you give up control over the attributes of the root SOAP Body element. So how do you change the namespace, the prefix, or attributes of the root element?