SOAP::Data

The SOAP::Data class allows you specify a value, name, type, URI, or other attributes for SOAP elements. For example, you can serialize the name/value pair of “Nate/31” with the following code:

SOAP::Data->name('Nate')->value(31);

This becomes <Nate>31</Nate>.

You can also import SOAP::Data methods with import( ). To import 'name':

SOAP::Data->import('name');

Once imported, 'name' can be used as follows:

name(Nate => 31);

SOAP::Data also provides an interface to get or set specific attributes, including actor( ), mustUnderstand( ), encodingStyle( ), and root( ). For example:

SOAP::Data
    ->name(Nate => 31)
    ->encodingStyle('http://www.some.site/soap/showmetheliteral');

This is serialized as follows:

<Nate SOAP-ENV:encodingStyle="http://www.some.site/soap/showmetheliteral"
   xsi:type="xsd:int">31</Nate>

Get Perl in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.