[英]Why the 500 when calling web service method?
我得到500,[ArgumentException:未知的Web方法GetFacilityInfo。 参数名称:methodName]。 看起来一切都井井有条。 搜索该问题的大多数结果是人们对于是否使用静态方法感到困惑,但是您可以看到我正确地不使用静态方法,因为它是实际的Web服务。
var数据内容:
clientId:“ DevClient”工具Id:“ 2”
网络服务:
namespace Sentry.WebMethods
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public class FacilityInfoService : WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public FacilityInfo GetFacilityInfo(string facilityId, string clientId)
{
try
{
var helper = ObjectFactory.GetInstance<EditCheckDataHelper>();
var facility = helper.GetFacility(Convert.ToInt16(facilityId), clientId);
return facility;
}
catch (Exception ex)
{
ErrorSignal.FromCurrentContext().Raise(ex);
return new FacilityInfo();
}
}
}
}
JavaScript调用:
var xhr = $.ajax({
type: "post",
data: JSON.stringify(data),
url: postUrl,
dataType: "text",
contentType: "application/json; charset=utf-8",
async: false,
success: function (respScript) {
if (xhr.status == 200) {
return JSON.parse(respScript).d;
}
},
error: function (xhrObj) {
if (xhrObj.status > 0) {
alert("[" + xhrObj.status + "] Failed to retrieve facility info.");
}
},
complete: function () {
}
});
问题是,由于没有非常明显的方法可以通过Visual Studio添加Web服务.asmx文件(请启发我-Premium 2012),因此我复制粘贴了另一个.asmx文件,它指向了标记错误的课程。 (facepalm)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.