软件频道>程序开发>JavaVBVCDelphiC/C++Web开发微软专栏移动数据库程序人生软件工程|开发客
您现在的位置: 天极网 > 开发频道 > 化零为整WCF(7)-消息处理(使用消息传输优化机制-MTOM)
全文

化零为整WCF(7)-消息处理(使用消息传输优化机制-MTOM)

2008-05-25 07:00作者:webabcd出处:天极网责任编辑:nancy

  介绍

  WCF(Windows Communication Foundation) - 消息处理:MTOM(Message Transmission Optimization Mechanism) - 消息传输优化机制。本文以web方式上传大文件为例。

  示例

  1、服务

  IMtom.cs


  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using System.ServiceModel;
  using System.IO;
  
  namespace WCF.ServiceLib.Message
  {
   /**//// 
   /// IMtom接口
   /// 
   [ServiceContract]
   public interface IMtom
   {
   /**//// 
   /// 上传文件
   /// 
   /// 文件目标路径
   /// 文件字节数组
   [OperationContract]
   void UploadFile(string path, byte[] fileData);
   }
  }
  

  Mtom.cs

 


 using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using System.ServiceModel;
  using System.IO;
  
  namespace WCF.ServiceLib.Message
  {
   /**//// 
   /// Mtom类
   /// 
   public class Mtom : IMtom
   {
   /**//// 
   /// 上传文件
   /// 
   /// 文件目标路径
   /// 文件字节数组
   public void UploadFile(string path, byte[] fileData)
   {
   FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None);
   fs.Write(fileData, 0, fileData.Length);
   fs.Flush();
   fs.Close();
   }
   }
  }
  
共3页。 1 2 3 下一页 末页
相关搜索:
关注此文读者还看过
文章排行
本周
本月
最近更新
关于我们|About us|网站律师|天极服务|电子杂志|RSS订阅|加入我们|网站地图
TMG
Copyright (C) 1999-2009 Chinabyte.com, All Rights Reserved 版权所有 天极网络
商务联系、网站内容、合作建议:010-82657868
版权声明 在线提交意见反馈 渝ICP证B2-20030003号
经营性网站备案信息 网警备案 中国网站排名
天极传媒:天极网|比特网|IT专家网|IT商网|52PK游戏网|IT分众