【问题标题】:Problem with passing xml data to webservice .asmx将 xml 数据传递给 webservice .asmx 的问题
【发布时间】:2011-04-07 04:25:52
【问题描述】:

我有对 webservice jsonwebservice.asmx 的 ajax 调用,我的数据类型是 xml,我在将数据传递给 webservice 时遇到问题是任何语法问题

$.ajax({ 类型:“发布”, 异步:假, url: "/blkseek2/JsonWebService.asmx/GetList", 数据类型:“xml”, 数据: "keyword1="+keyword1+ "streetname="+address1+ "lat="+lat+ "lng="+lng+ "radius="+radius ,

             failure: function(XMLHttpRequest, textStatus, errorThrown) 
                     { ajaxError(XMLHttpRequest,textStatus, errorThrown); },
                success: function(xml) 
                 { ajaxFinish(xml); }



            });
            });
    });

【问题讨论】:

  • 你有什么错误信息?属性“数据”似乎不是 xml。

标签: c# javascript jquery


【解决方案1】:

尽量把数据做成xml。

$.ajax({ type: "POST", async: false, url: "/blkseek2/JsonWebService.asmx/GetList", datatype:"xml", data: "<?xml version='1.0'?><keyword1>"+keyword1+ "</keyword1><streetname>"+address1+ "</streetname><lat>"+lat+"</lat><lng>"+lng+ "</lng><radius>"+radius+"</radius>" ,

【讨论】:

  • 感谢回复,可以写webmethod如下图捕获客户端ajax调用传递的xml参数 [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Xml)] public XmlDocument GetList(string keyword1,字符串街道名称,字符串 lat,字符串 lng,字符串半径){ XmlDocument xmldoc= CreateXML(keyword1,streetname,lat,lng,radius); // xmlDoc.Save(@"C:\Documents and Settings\Vijay.EKO-03\Desktop\blkseek2\Block3.xml");返回xmldoc; }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-04
  • 2011-07-23
相关资源
最近更新 更多