This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Chapter 12: Advanced Web Services Topics
The SOAP::Lite module provides transparent access to data packaged this way (there
is nothing to do on the client or server side to accept MIME-encoded messages; the
value of the image element in this example will be the picture itself when accessed
SOAP::Lite), however, the current version (0.55) doesn’t help to create mes-
sages with attachments. The
SOAP::MIME package (created by Byrne Reese and avail-
able from CPAN) extends support for parsing MIME messages providing direct
access to the attachments and also allows composing messages with attachments. Its
interface is simple:
use SOAP::Lite;
use MIME::Entity;
my $cid = "bar";
my $ent = build MIME::Entity
Type => "image/gif",
Encoding => "base64",
Path => "image.gif",
'Content-Id' => "<$cid>",
Disposition => "attachment";
my $som = SOAP::Lite
->send_image(SOAP::Data->name("foo")->attr({href => "cid:$cid"}));
It’s quite possible that this functionality will be included in a future version of the
SOAP::Lite module.
DIME and WS-Attachments
The structure of DIME message is somewhat similar to the structure of MIME mes-
sages (yet it uses a different terminology). Parts are called records and they consist of
a header and a payload, which can be either a complete object or a chunk of an
object. Similar to the MIME format, DIME uses headers to carry metadata about an
object encoded in a payload.
There are several important differences between the DIME and MIME formats. First,
MIME identifies the structure of content stored in the body by a type specified in a
Content-Type header, whereas DIME indicates the type of the payload in two ways.
The first way is identical to the usage of MIME media type as type identifier; the sec-
ond (optional) method defines the type through the use of the URI. The second dif-
ference between the formats is that even though DIME records are 32-bit word
aligned variable length records, each record includes a fixed length binary array with
flags and lengths of four elements that follow:
result, the length of the record is always known, and it’s easy to implement random

Get Programming Web Services with Perl now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.