最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用wse(Web Services Enhancements )把服务器端的文件传到客户端
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
比如说,现在站点A有个附件想传给站点B,我们就可以用WSE来传。
在服务器端的webservice文件service1.asmx中写入webmethod:
这个是取附件的方法:
[WebMethod]
public void GetAttachment()
{
// 获取 SoapContext 作为响应消息
SoapContext myContext = HttpSoapContext.ResponseContext;
// 字符串,表示附件的文件名和路径。
string filePath = @"C:My Documents1.txt";
// 使用文件名来创建新的 DIME 附件,
// 并通过 MIME 媒体类型
// 来指定附件编码。
DimeAttachment dimeImage = new DimeAttachment(
"text/xml", TypeFormatEnum.MediaType,
filePath);
// 指定给 DIME 记录的 ID 属性。
dimeImage.Id = "1.txt";
// 将新的 DimeAttachment 对象添加到 SoapContext 对象中。
myContext.Attachments.Add(dimeImage);
}
在客户端的web站点下载附件,并写入到新的文件中:
private void DownAttachment()
{
//Service1WSE : Microsoft.Web.Services.WebServicesClientProtocol 这里的Service1继承WSE 中的类
Service1WSE sw=new Service1WSE();
//从webservice中获取附件
sw.GetAttachment();
//得到附件的流
Stream str=sw.ResponseSoapContext.Attachments[0].Stream;
int length=(int)str.Length;
-
上一个: 用WSE在Web服务中验证用户身份
-
下一个: 一次编程实践[ASP+MSSQL]
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14