-
大小: 132KB文件类型: .zip金币: 2下载: 0 次发布日期: 2022-10-03
- 语言: C#
- 标签: ASP.NET WebService
资源简介
使用 ASP.NET/C# 实现的 WebService。用于接收来自客户端REST方式上传的照片和说明。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.xml;
using System.IO;
using System.Text;
using System.Collections.Specialized;
namespace FirstPlace
{
///
/// Summary description for PhotoNotes
///
[WebService(Namespace = “http://www.sunyong.com.cn/JieSi/FirstPlace“)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script using ASP.NET AJAX uncomment the following line.
// [System.Web.script.Services.scriptService]
public class PhotoNotes : System.Web.Services.WebService
{
[WebMethod]
public xmlDocument UploadData()
{
StringBuilder sb = new StringBuilder();
string result = string.Empty;
try
{
HttpFileCollection httpFiles = Context.Request.Files;
HttpPostedFile filePhoto = httpFiles[“media“];
string localPhotoFile = Path.Combine(Server.MapPath(“.“) filePhoto.FileName);
filePhoto.SaveAs(localPhotoFile);
NameValueCollection formVars = Context.Request.Form;
string hdrMsg = formVars[“message“];
string msgFile = string.Format(“{0}.{1}“ Path.GetFileNameWithoutExtension(filePhoto.FileName) “txt“);
string localMsgFile = Path.Combine(Server.MapPath(“.“) msgFile);
using (StreamWriter sw = File.Exists(localMsgFile) ? File.CreateText(localMsgFile) : new StreamWriter(localMsgFile))
{
sw.WriteLine(string.Format(“[{0}] {1}: {2}“ DateTime.Now filePhoto.FileName hdrMsg));
}
result = “success“;
}
catch (System.Exception ex)
{
result = string.Format(“fail: {0}“ ex);
}
sb.AppendFormat(“l>{0} l>“ result);
xmlDocument xmlDoc = new xmlDocument();
xmlDoc.Loadxml(sb.ToString());
return xmlDoc;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-02-01 14:02 FirstPlace\
目录 0 2012-02-01 16:50 FirstPlace\FirstPlace\
文件 920 2012-02-01 14:02 FirstPlace\FirstPlace.sln
文件 15872 2012-02-01 16:50 FirstPlace\FirstPlace.suo
目录 0 2012-02-01 14:02 FirstPlace\FirstPlace\App_Data\
文件 4101 2012-02-01 14:03 FirstPlace\FirstPlace\FirstPlace.csproj
文件 1297 2012-02-01 14:03 FirstPlace\FirstPlace\FirstPlace.csproj.user
文件 124662 2012-02-01 16:02 FirstPlace\FirstPlace\image.jpg
文件 562 2012-02-01 16:02 FirstPlace\FirstPlace\image.txt
文件 96 2012-02-01 14:03 FirstPlace\FirstPlace\PhotoNotes.asmx
文件 2246 2012-02-01 16:01 FirstPlace\FirstPlace\PhotoNotes.asmx.cs
目录 0 2012-02-01 14:02 FirstPlace\FirstPlace\Properties\
文件 1391 2012-02-01 14:02 FirstPlace\FirstPlace\Properties\AssemblyInfo.cs
文件 8061 2012-02-01 14:43 FirstPlace\FirstPlace\Web.config
相关资源
- Asp.net学生信息管理系统源码
- asp.net C#购物车源代码
- ASP.NET实验室预约管理系统
- 020ASP.NET车辆综合管理系统.zip
- c# 高校档案信息管理系统
- asp.net中c#做的躲避小游戏,希望大家
- ASP.NET C# 工资管理系统
- ASP.NET客户管理系统(毕业设计 C#
- 在线求职系统(C#ASP.NET源码)
- asp.net 在线考试系统及论文
- ASP.Net文件上传管理源码
- 《OA企业办公自动化》asp.net 源码(附
- asp.netc#开发规范
- asp.net 大文件上传(带进度条)
- 通过程序自动填充并提交ASP.NET表单(
- ASP.NET 基础编程文档(PPT电子教案)
-
ASP.NET_xm
l深入编程技术 - asp.net 新闻发布系统源码(附文档以及
- asp.net 简单的Ajax应用
- asp.net 企业官网源码(附数据库)
- asp.net 花语花店销售网站源码(含数据
- ASP.NET资产管理系统源码(附数据库)
- ajax 登录(基于asp.net)
- asp.net 简单新闻发布系统源码(附数据
- asp.net新闻发布系统(源码+数据库+论
- asp.net网上购物系统源码
- ASP.NET 在浏览器中预览文件
- asp.net 生命周期
- asp.net 花语花店销售网站源码(附数据
- asp.net 购物车实现(基于Session)
评论
共有 条评论