日期:2014-05-20  浏览次数:20809 次

想了解诶我这样设计的接口的优缺点
我现在的接口是这样的 新建一个aspx的文件
然后通过string.IsNullOrEmpty(Request["useName"] 获取参数
最后
  string xmlName = DateTime.Now.Ticks.ToString() + ".xml";

  XmlTextWriter xtw = new XmlTextWriter(Server.MapPath("~/Upload/" + xmlName + ""), //生成XML

  Encoding.GetEncoding("utf-8"));//设置encoding类型为:utf-8

  xtw.WriteRaw("<?xml version=\"1.0\" encoding=\"utf-8\"?>");//表头

  ds.DataSetName = "useReg";//这里改了dataSet对像的名称,对应了XML文档的根结点 

  ds.WriteXml(xtw);

  xtw.Close();

  string fileName = "backInfo.xml";//客户端保存的文件名
  string filePath = Server.MapPath("~/Upload/" + xmlName + "");//路径

  //以字符流的形式下载文件
  FileStream fs = new FileStream(filePath, FileMode.Open);
  byte[] bytes = new byte[(int)fs.Length];
  fs.Read(bytes, 0, bytes.Length);
  fs.Close();
  Response.ContentType = "application/octet-stream";
  //通知浏览器下载文件而不是打开
  Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
  Response.BinaryWrite(bytes);
  Response.Flush();
  File.Delete(filePath);
  Response.End();
返回XML

想了解这样的接口有什么缺点?
和webservice相比性能上如何,是否需要把接口改成webservice
谢谢大家了


------解决方案--------------------
没什么问题。
只是你这个不具有推广,复用的优点,不通用。但局部挺好的。
------解决方案--------------------
不用soap很多年。。。
------解决方案--------------------
你这样写挺好。
------解决方案--------------------
对于调用方,你这方式就不如webservice简单。

其他倒是没什么。
------解决方案--------------------
你的已经基本上是实现层了。。。
谈接口。。。。