A simple SOAP message sent over HTTP protocol usually has a content type of "text/xml". Although you could include a binary attachment as a parameter to a Web service method call, this carries overhead since the data is encoded as xs:base64 or xs:hexbinary (embedded or referenced), adding bloat to the message. Furthermore, it is inefficient for XML parsers to resolve these references, and unwrap the attachment while parsing the SOAP message. To address this several standards emerged for handling SOAP message attachments. SOAP with Attachments is the original W3C recommendation to define how SOAP messages are carried within a MIME "multipart/related" message, as a compound SOAP document. The first MIME part is the SOAP envelope, subsequent parts contain attachments. SOAP with Attachments addressed the problem of reducing payload overhead, but did not provide a formal way to associate attachments with the SOAP message.
DIME and WS-Attachments specifications evolved to improve on this. DIME is similar to MIME, but is an alternate binary message format that supports the compilation of a message with arbitrary types. Rather than a content type "multipart/related" it is packaged as "application/dime" so that those receiving the message can parse it accordingly. WS-Attachments describes how to encapsulate SOAP message in DIME.
To ultimately answer your question, the Web services toolkits support adding attachments to SOAP messages using an object model, so that you are abstracted from the details of populating HTTP headers and building the compound SOAP message. Thanks to the generation of Web service proxies, in a few lines of code you can create a DIME attachment from a binary stream, attach it to the outgoing attachments collection, and invoke the Web service method, as shown here for a .NET Web service.
DimeAttachment attachment = new DimeAttachment("image/jpeg", TypeFormatEnum.MediaType, data); svc.RequestSoapContext.Attachments.Add(attachment); svc.SignAttachment(text);In short, when you send attachments to a Web service, today's toolkits have standardized on DIME/WS-Attachments. This will likely evolve to accommodate encryption, digital signatures and other features not currently supported, and the names of the standards may even change, but for now this is the way to go.
As a teaser, I have included the links to some newly emerging discussions on SMTOM whose roots derive from PASWA. See below.
For more on DIME/WS-Attachments see the articles titled "Fun with WS-Attachments" and "Getting Started with WSE" at the following link: http://www.dotnetdashboard.net/DesktopDefault.aspx?tabindex=7&tabid=73
Dig Deeper on Topics Archive
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.