Tag: web services

asmx web服务在.net 4.0中返回xml而不是json

我刚刚将我的网站的测试副本升级到asp.net 4.0,并注意到一个奇怪的问题,只有当我将网站上传到我的服务器时才会出现。 该站点有一个返回json的asmx Web服务,但当我在我的服务器上运行该站点时,它返回xml。 它在asp.net 3.5中运行良好超过一年。 webMethod用正确的属性装饰…… [WebMethod][ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List RecentChanges() 在我的本地机器上它返回json。 然而在服务器(Windows 2008 64位)上它返回xml。 使用firebug控制台,你会看到200 OK响应和一堆XML,在我的本地机器上返回的数据是我期望的JSON。 这是调用服务的JavaScript。 function loadRecentData() { $.ajax({ type: “POST”, url: “service/spots.asmx/RecentChanges”, data: “{}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: loadRecentUpdates, failure: function(msg) { //alert(msg); } }); } 欢迎任何建议,这让我难过!

如何跟踪ScriptService WebService请求?

我有一个SoapExtension,旨在记录所有SOAP请求和响应。 它适用于使用MS Soap Toolkit(OnBase Workflow)的应用程序调用。 但它不适用于$ .ajax()在html页面上进行的调用。 这是一个例子: $.ajax({ type: “POST”, url: url, data: data, contentType: “application/json; charset=utf-8”, dataType: “json” }); 它调用标记有WebService和ScriptService属性的ASP.NET 3.5 WebService: [WebService(Namespace = XmlSerializationService.DefaultNamespace)] [ScriptService] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class DepartmentAssigneeService : WebService { private readonly DepartmentAssigneeController _controller = new DepartmentAssigneeController(); /// /// Fetches the role items. /// /// [WebMethod] [SoapLog] public […]

从webservice解析日期

我从Web服务中获取日期,它们看起来像这样: /Date(1310187160270+1200)/ 我如何在javascript中将其转换为日期对象? 我已经google了一下,找不到一个合适的答案 – 这可能部分是由于我不确定这种类型的日期对象被调用的事实 – 所以如果有人能够阐明这一点,那么不胜感激。

Web服务显示Jquery令牌输入结果的正确响应应该是什么?

我正在使用Jquery令牌输入插件。 我试图从数据库中获取数据而不是本地数据。 我的Web服务返回json结果包装在xml中: [{“id”:”24560″,”name”:”emPOWERed-Admin”},{“id”:”24561″,”name”:”emPOWERed-HYD-Visitors”}] 我已经在http://loopj.com/jquery-tokeninput/网站上查了一下,该网站说该脚本应该按以下格式输出JSON搜索结果: [ {“id”:”856″,”name”:”House”}, {“id”:”1035″,”name”:”Desperate Housewives”} ] 两者似乎都是相同的,但仍然没有得到我的页面中显示的项目。 我也发布了我的代码。 我的Js代码:DisplayTokenInput.js $(document).ready(function() { $(“#textboxid”).tokenInput(‘PrivateSpace.asmx/GetDl_info’, { hintText: “Type in DL Name”, theme: “facebook”, preventDuplicates: true, searchDelay: 200 }); }); 我的网络服务代码: [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public string GetDl_info(string q) { string dl_input = string.Empty; DataSet ds; PSData ObjDl = new PSData(); ds […]

使用jquery调用ascx页面方法

我知道我可以使用以下语法使用jquery调用页面方法 $.ajax({ type: “POST”, url: “Default.aspx/GetDate”, data: “{}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { // Replace the div’s content with the page method’s return. $(“#Result”).text(msg.d); } }); 这适用于aspx页面但是可以使用ascx页面吗? (网页控制) 我已经尝试了大约半个小时,因为我无法让它工作,我想知道它是否可能。 注意:为了清楚,当我尝试调用ascx页面时,我正在更新jquery中的url 🙂

jQuery ajax发布到Web服务

$(document).ready(function() { $.ajax({ type: “POST”, url: “/getprojects.ashx”, data: “”, dataType: “text/xml”, cache: false, error: function() { alert(“No data found.”); }, success: function(xml) { alert(“it works”); alert($(xml).find(“project”)[0].attr(“id”)); } }); }); 我的问题是我得到一些数据,但我似乎无法显示它。

可以jquery ajax调用外部webservice?

jquery ajax代码可以从另一个域名或其他网站调用web服务吗? 像这样: $.ajax({ type: “POST”, url: “http://AnotherWebSite.com/WebService.asmx/HelloWorld”, data: “{‘name’:'” + $(‘#price’).val() + “‘}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) {alert(msg);} }); 我应该如何配置这个Web服务?

如何从2.0 asmx Web服务返回JSON

我使用.Net framework 2.0 / jQuery来对2.0 Web服务进行Ajax调用。 无论我在ajax调用中将contentType设置为什么,服务总是返回XML。 我想让它回归Json! 这是电话: $(document).ready(function() { $.ajax({ type: “POST”, url: “DonationsService.asmx/GetDate”, data: “{}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { // Hide the fake progress indicator graphic. $(‘#RSSContent’).removeClass(‘loading’); // Insert the returned HTML into the . $(‘#RSSContent’).html(msg.d); } }); }); 以下是Fiddler中请求标头的样子: POST /DonationsService.asmx/GetDate HTTP/1.1 x-requested-with: XMLHttpRequest Accept-Language: en-us Referer: […]

jqgrid添加行并将数据发送到webservice以进行插入

我已经能够使用jQuery / Ajax从Web服务中将数据从我的数据库中提取到jQGrid中。 现在我想将添加/编辑的数据发送回webservice。 我通过使用PHP和editurl:命令看到了一些例子。 这也适用于Web服务(就像我最初下载数据一样)? 我已多次查看这些例子了。 我甚至发现了另一个类似于我所问的问题 ,但是我找不到任何关于如何做我需要的实例。 有存在吗? :更新: jQuery(document).ready(function () { jQuery(“#list”).jqGrid({ datatype: processrequest, mtype: ‘POST’, jsonReader: { root: “ListExercise”, //arry containing actual data page: “Page”, //current page total: “Total”, //total pages for the query records: “Records”, //total number of records repeatitems: false, id: “ID” //index of the column with the PK […]