如何引用从 web 服务文件构建和保存的生成的 xml 文件

Posted

技术标签:

【中文标题】如何引用从 web 服务文件构建和保存的生成的 xml 文件【英文标题】:How to refer the resultant xml file which is being constructed and saved from webservice file 【发布时间】:2011-04-08 14:55:17 【问题描述】:

这是我的 web 服务代码,它执行构造 xml 文件并存储到特定目标,这是存储生成的 xml 文件的正确方法吗,或者请让我知道他们是否有任何替代程序这样做。 [WebService(命名空间 = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.Web.Script.Services.ScriptService] 公共类 JsonWebService : System.Web.Services.WebService

XmlDocument xmlDoc = new XmlDocument();

公共字符串关键字; 公共 JsonWebService ()

    //Uncomment the following line if using designed components 
    //InitializeComponent(); 

[网络方法] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public bool GetList(string keyword1, string streetname, string lat, string lng, string radius)

  XmlDocument xmlDoc=  CreateXML( keyword1,streetname,lat,lng,radius);
    //save file to application folder which will be refferd by client application
  xmlDoc.Save(@"C:\Documents and Settings\Desktop\block\Block3.xml");
  return true;


我无法从客户端应用程序引用在 web 服务中构建的 xml 文件 这将是我在客户端的代码,这是引用保存的 xml 文件的正确方法吗 功能搜索位置附近() var searchUrl="http://localhost:2385/blockseek3-9-2010/Block3.xml"; //引用存储在应用程序文件夹中的xml文件 GDownloadUrl(searchUrl, 函数(数据) var xml = GXml.parse(data); var 标记 = xml.documentElement.getElementsByTagName('marker'); map.clearOverlays(); ………… ………… ........

【问题讨论】:

【参考方案1】:

我会将 XML 文件存储在服务器上的某个 可配置 位置 - 它可能涉及为文件或子文件夹(将存储文件)创建一个唯一名称。我可能会为此目的使用 GUID,然后服务会将这个唯一名称返回给客户端。客户端可以使用另一个处理程序(例如 Download.ashx)将该文件获取到客户端,或者您可以将虚拟目录映射到您的位置并使用该路径,例如[站点]\Saved Files[唯一名称]\block3.xml 其中“Saved Files”是映射到文件保存位置的虚拟目录。

【讨论】:

以上是关于如何引用从 web 服务文件构建和保存的生成的 xml 文件的主要内容,如果未能解决你的问题,请参考以下文章

如何从我的 Web 服务器传送加密文件?

在保存文件时,如何让 eclipse m2e 构建当前项目和引用它的 EAR 项目?

从Visual Studio构建定义UI添加MSBuild的引用搜索文件夹

我将如何将 JSON 文件从 web 服务保存到本地 JSON 文件?

如何使用 javascript 从 Web 服务返回的二进制字符串构建 PDF 文件

Hibernate 5.x和Spring Data 2.x:如何在服务保存方法中更新原始对象