TechBubbles Microsoft Technology BLOG

MTOM Support to Web Service

Overview of MTOM

Using MTOM an application can send or receive a large amount of data. MTOM allows message-level security to be applied to the message including binary data. MTOM encodes the SOAP message and transmits the message as XML.

Following is the procedure to send large amount of data using MTOM

  1. Open the web service project in Visual studio 2005

  2.   Enable the project to use WSE by

        a. In solution explorer right click the project and then click WSE Settings

        b. Select the general tab

        c. Select Enable this project for Web Services Enhancements and 

           Enable Microsoft Web Services Enhancements SOAP Protocol 

           Factory.

3. Specify that web service can accept SOAP messages encoded using MTOM.

        a. In solution explorer right click the project and then click  WSE Settings.

        b. Select the Messaging tab.

        c. Choose optional or always for the Server Mode.

           always MTOM mode specifies that all incoming and outgoing SOAP  

           messages must be MTOM encoded.

           optional MTOM mode specifies that whether or not all incoming and  

           outgoing messages can be encoded.

Define a Web service method that returns a byte array.

[WebMethod]
public byte[] GetFile(string fileName)

{

    byte[] response;
    String filePath = AppDomain.CurrentDomain.BaseDirectory 
+ @"App_Data\" + fileName;
    response = File.ReadAllBytes(filePath);
    return response;

}

4. Configure the Web server to handle the larger amount of data.

<configuration>
  <system.web>
  <httpRuntime maxMessageLength="409600"
    executionTimeoutInSeconds="300"/>
  </system.web>
</configuration>

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

3 Comments

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud