Articles
Using Web Services Enhancements to Send SOAP Messages with Attachments," MSDN Online, February 2003.
a reader Hi, Jeannine,I have read your technical document "Using Web Services Enhancements to Send SOAP Messages with Attachments" and I have some questions about how to using "DimeAttachment".
1. in your document you use DimeAttachment dimeImage = new DimeAttachment("image/jpeg", TypeFormatEnum.MediaType, filePath); to send a binary JPEG image file. Now I want to using public DimeAttachment(string type, TypeFormatEnum Format, string path); to send a binary EXE image file named LoadFlow.exe. Then how should I set the type, TypeFormatEnum Format for DimeAttachment?
2. In my another project I want to sent TXT, DAT, Cir files, Then how should I set the type, TypeFormatEnum Format for DimeAttachment?
author The easiest thing to do is to use a MIME media type and specify TypeFormatEnum.MediaType for the format. You can find a list of MIME media types at http://www.iana.org/assignments/media-types/ I don't think that the media type affects how the DIME message is constructed, it is only to tell the recipient how to handle the attachment. For example, for your first file I would use:
DimeAttachment("application/octet-stream",TypeFormatEnum.MediaType,"loadflow.exe")
and for the second:
DimeAttachment("text/plain",TypeFormatEnum.MediaType,"LeesMij.txt")
In general, you should use a MIME media-type that makes the most sense. If you cannot find an exact type, use "application/octet-stream" for binary and "text/plain" for ASCII text.

a reader I read and enjoyed your MSDN article "Sending Files, Attachments, and SOAP Messages Via Direct Internet Message Encapsulation". However, I have a technical question, that perhaps you might address: I have created a .Net web service using DIME for passing large file binary files from the client to the server. The system works fine with a .Net client, but I need to create a client in VB6 using the SOAP toolkit v3 (STK). Is this possible? The problem is that the web service method expects a collection of Dime Attachments as a property of the Soap RequestContext, not as a method parameter. The STK supports DIME attachments, but the samples and documentation for the STK seem to assume that the web service method provides a parameter for the collection of DimeAttachments. Is there a way with STK to get the DimeAttachments collection into the RequestContext of the SOAP call as the .Net service is expecting?
author I assume that by .NET you mean that you are using the DIME support provided by WSE 1.0 (Microsoft.Web.Services). For the most part, STK3.0 does interop with WSE1.0, however, both handle attachments in a slightly different way. When using STK3 to build a DIME message containing a SOAP message and attachments, a (mostly) WS-Attachments-compliant DIME message is sent. When the WSE runtime receives this type of DIME message, it parses it to extract the primary SOAP message and any attachments. These attachments automatically get added to a DimeAttachmentCollection object. In such a case, the collection should already be accessible in the RequestContext for the incoming request message, as in the following example:
[WebMethod]
public void SendImages()
{
  SoapContext myContext =
   HttpSoapContext.RequestContext;
  if (myContext.Attachments.Count > 0)
  {
    foreach(DimeAttachment myAttach in
     myContext.Attachments)
    {
      // write attachment to file, or do whatever
    }
  }
}

a reader Dear madam, I'm a student at the university of Pisa in Italy, working on a project concerning web services. I have read an article, "Sending Files, Attachments, and Messages Via Direct Internet Message Encapsulation", written by you and published in MSDN Magazine in December 2002. In this article, you said that one of the reasons DIME is used to send binary data is to avoid all the encoding and decoding necessary when using the base64 encoding.. you also said that this encoding and decoding is not a good idea when the document is digitally signed. I don't understand this last affirmation; if a digitally signed document is modified in any way, it is considered to be no longer valid.. what are the possible modifications that the document could encounter using the base64 encoding instead of sending it as an attachment?
author The issue is not so much that the signature on a binary would necessarily be invalidated by encoding as base64 binary XML. However, it can become cumbersome to sign binary objects where the signatures need to be validated by intermediaries during the process. To validate a signature on a signed binary object that is being sent base64 encoded, the object would need to be properly decoded to binary to validate the signature before re-encoding it to send on its way.

a reader Jeannine, I've read your article on SOAP and DIME attachments but I have a question regarding SOAP attachments in general. We have a need for our Unix engineers to access our .NET repository from a command line. As far as I see it one of two ways to do this is either from a Java program or Perl and SOAP::Lite scripts from our exposed web services. At the current time I can access our repository from a command line in Unix with Perl and SOAP::Lite. However, the real need is for engineers to request files from our repository. SOAP and web services seem the logical choice but it appears that the SOAP::Lite implementation does not understand DIME attachments only MIME attachments. Do you know or is it possible to attach files to a web servcie using the MIME protocol? If this is not a feasible solution, do you know of another method to accomplish this?
author If you need to use MIME, there is a separate proposed mechanism for MIME with SOAP known as SOAP with Attachments (SwA). You can read more at: http://www.gotdotnet.com/team/mgudgin/paswa/paswa.html