Home > Ask the SOA Experts > Questions & Answers > Uploading files with Web services
Ask The SOA Expert: Questions & Answers
EMAIL THIS

Uploading files with Web services

Michèle Leroux Bustamante EXPERT RESPONSE FROM: Michèle Leroux Bustamante

Pose a Question
Other SOA Categories
Meet all SOA Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 25 February 2004
How do we can upload a file using Web services from a client (Windows forms with C#.NET) as we can do file upload using enctype="multipart/form-data" in HTML?


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Microsoft .NET Web services
How do I balance throughput requirements and interoperability?
APM software traces transactions across tiers, technologies
How you can learn M Grammar for Oslo modeling
Legacy modernization opens Windows for publisher
Former .NET Web developers ride Ruby and Rails application framework
Microsoft Oslo at PDC: Dial 'M' for modeling language
Yahoo proxy fight looms
New Microsoft site for architects
LAMP coders go hybrid route
Silverlight shines on bank RIAs
Microsoft .NET Web services Research

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
Common Language Infrastructure  (SearchSOA.com)
Visual J#  (SearchSOA.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


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.

Specification links:
http://www.w3.org/TR/SOAP-attachments
http://www.ietf.org/internet-drafts/draft-nielsen-dime-soap-01.txt
http://www.ietf.org/internet-drafts/draft-nielsen-dime-02.txt
http://www.w3.org/TR/SOAP-attachments
http://www.w3.org/TR/soap12-mtom/
http://www.gotdotnet.com/team/jeffsch/paswa/paswa61.html

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




Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SOA Governance White Papers - BPM, EDA, IT Governance
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2001 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts