Tag: web services

500错误 – JSON对象POST到.ASMX webservice

保持这个问题简短而甜蜜。 当我尝试将JSON对象传递给ASMX Web服务时,我收到500错误。 请注意,如果我将params声明为单个变量 (例如int ID, int OrderHeaderID等) ,则不会收到错误 。 我不明白为什么会出现这个问题,我之前已经成功地以这种方式传递了对象,可能使用了不同的语法,但我记不得了。 JS: var returnHeader = { ID: -1, OrderHeaderID: parseInt(getQueryStringKey(‘OrderID’)), StatusID: 1, DeliveryCharge: 0, CreatedBy: $(‘span[id$=”lblHidUsername”]’).text(), ApprovedBy: $(‘span[id$=”lblHidUsername”]’).text() }; $.ajax({ type: “POST”, url: ‘Order.asmx/SaveReturnHeader’, contentType: “application/json; charset=utf-8”, dataType: “json”, data: JSON.stringify(returnHeader), success: function (result) { if (result.Status == ‘OK’) { GetReturns(); } else { $(‘#divMessage’).show().html(result.Data.Message).addClass(‘error’); […]

Ajax jquery调用获取NetworkError:403 Forbidden错误响应

我使用apache tomcat作为Web服务器。 我在tomcat上部署了webservices。 如果我通过jquery ajax从本地文件系统发送请求到tomcat webservice作为响应我收到403错误。 如果我从同一个容器运行相同的脚本,我将从Web服务获得有效的响应。 我正在使用以下代码。 function callservice() { jQuery.support.cors = true; var mobNo = document.getElementById(‘mobileNo’).value; var acctNo = document.getElementById(‘accountNo’).value; //var id = document.getElementById(‘id’).value; var custNo = document.getElementById(‘customerId’).value; //var mobNo = document.getElementById(‘txt_name’).value; //alert(“mobileNo” + mobNo+”accountNo” + acctNo+”customerId “+custNo); var url = “http://localhost/mobile-services/rest/user/”; var dataVal = {}; dataVal[“mobileNo”] = mobNo; dataVal[“accountNo”] = acctNo; dataVal[“customerId”] […]

在传递给Web服务之前,将jqGrid rowNum从ALL更改为-1的最佳方法

我正在寻找允许用户选择在jqGrid中显示所有记录的最佳方法。 我知道为rows参数传递的-1值表示ALL,但我想在rowList select元素中出现单词“ALL”而不是-1,即。 rowList:[15,50,100,’ALL’]。 我将网格请求传递给一个接受“行”的int的Web服务,我正在尝试找到如何以及何时将用户选择的“ALL”值更改为-1,然后再将其发送到网络服务。 下面是我清理过的网格代码。 我在数据类型函数中的$ .ajax之前尝试了一些不同的代码块。 但大多数尝试似乎都是我必须以最可能的方式做到这一点。 例如, datatype: function(postdata) { if ($(“#gridTableAssets”).jqGrid(‘getGridParam’, ‘rowNum’) == ‘ALL’) { $(“#gridTableAssets”).appendPostData({ “rows”: -1, “page”: 1 }); } $.ajax({… 但这样做似乎会导致实际的“页面”GridParam在后续的网格操作中被忽略,迫使我在其他地方处理它。 似乎这是经常在那里做的事情并且有干净的方式做到这一点。 清理网格代码: $(“#gridTableAssets”).jqGrid({ datatype: function(postdata) { $.ajax({ url: “/Service/Repository.asmx/GetAssets”, data: JSON.stringify(postdata), type: ‘POST’, contentType: “application/json; charset=utf-8”, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(‘error’); }, success: function(msg) { var […]

使用jQuery从纯HTML网站调用.net webservice

我想知道可以使用jQuery从HTML页面调用托管的.net Web服务吗? 我尝试了这段代码,但它对我不起作用: $(‘#myForm’).click(function() { $.ajax({ type: “POST”, data: ‘{}’, url: “http://localhost:49590/Service.asmx?op=HelloWorld”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(response) { alert(response.d); }, failure: function(result) { alert(result.status + ‘ ‘ + result.statusText); } }); }); Web服务就是这样的: [WebService(Namespace = “http://tempuri.org/”)] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET […]

403禁止错误

当我从jquery访问web服务时,我收到403禁止错误..我也在虚拟目录中发布和创建。 Wat是造成这个错误的原因以及如何纠正它? 我在同一个解决方案中添加了webservice ..这是我的以下代码.. $(document).ready(function() { $(“#sayHelloButton”).click(function(event){ $.ajax({ type: “POST”, url: “App_Code/DummyWebService.asmx/HelloToYou”, data: “{‘name’: ‘” + $(‘#name’).val() + “‘}”, contentType: “application/json; charset=utf-8”, dataType: “json”, success: function(msg) { AjaxSucceeded(msg); }, error: AjaxFailed }); }); }); function AjaxSucceeded(result) { alert(result.d); } function AjaxFailed(result) { alert(result.status + ‘ ‘ + result.statusText); } 我想使用webservice的url路径是错误的..我使用了路径’DummyWebservice.asmx’。 我收到了500内部服务器错误。

最有效*用Jquery ajax填充select的方法

我有几个选择,我使用JQuery Ajax填充。 大多数负载很好。 但是,这些查询中有一个或两个,在少数情况下会向选择返回大量记录。 我想知道我填充选择的方式是否是从客户端代码执行此操作的最有效方法。 我省略了一些东西,使代码更短。 $(function () { FillAwcDll() }); function FillAwcDll() { FillSelect(‘poleDdl’, ‘WebService.asmx/Pole’, params, false, null, false); } function ServiceCall(method, parameters, onSucess, onFailure) { var parms = “{” + (($.isArray(parameters)) ? parameters.join(‘,’) : parameters) + “}”; // to json var timer = setTimeout(tooLong, 100000); $.ajax({ type: “POST”, url: appRoot + “/services/” + […]

Web应用程序+移动应用程序的技术堆栈

我正在构建一个Web应用程序+移动应用程序(Android和iPhone开始)。 我知道function,可以编写function规范。 我还没有决定是否应该构建本机应用程序或移动Web应用程序。 由于我将拥有可重用的function(由Web应用程序和移动应用程序使用),我应该将核心function作为Web服务公开并从视图中使用它(移动,Web UI等) 我的目标是加快建设速度。 应用程序/平台将来应该会很好地扩展。 我的预算很低,所以我正在寻找开源或低许可费用堆栈(Java,LAMP,开源等)。 我需要关于技术堆栈的建议。 如果您有类似的经历,请告诉我您的经历。 谢谢你们。

最佳实践 – 从Web服务中抛出exception

我们有一个ASMX Web服务,我们使用ajax(jQuery)从我们的ASP.NET应用程序调用它。 我们的Web方法的典型示例如下: [WebMethod] public void DoSomething(BusinessObject myParameter) { try { BL.DoSomethingWithParam(myParameter); } catch(Exception ex) { //logic to log the actual exception goes here //and then we throw a more user-friendly error as so: throw new Exception(“Unable to perform action such an such”); } } 在客户端,我们会有这样的事情: $.ajax({ type: “POST”, url: “WebService.asmx/DoSomething”, data: “{}”, contentType: “application/json; […]

是否可以从HTTPS向HTTP发出JSONP请求?

我知道有一个几乎重复的问题,但答案根本不令人满意。 我需要使用在HTTP上运行的Openstreetmap服务进行地理编码。 我的网站通过HTTPS运行。 似乎不可能从https到http进行JSONP请求,浏览器(Chrome)抱怨不安全的内容。 有解决方案?

使用网络服务获取NSE和BSE的股票报价,并使用json解析它

我想在简单的html页面上显示NSE和BSE的所有股票价格。 我从谷歌获得的信息,我可以调用已经存在的任何网络服务,他们将以jsonforms提供所有信息。 然后我必须解析jason代码。 现在我希望有人为我提供链接,我可以通过该链接调用webservice。 让我知道如何使用jQuery调用该Web服务。 我如何解析输出的json数据。 如果任何人可以给我样本代码那么它将是最好的.. 非常感谢你帮助我.. 🙂