本文介绍了出现问题“服务方法名称无效”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我无法在下面的案例中找出问题所在。我有一个webmethod并使用jquery ajax调用调用相同的方法。下面是代码。Hi All,I couldn't be able to figure out the problem in the below case. I have a webmethod and calling the same using jquery ajax call. Below is the code.[WebMethod(EnableSession = true)] [ScriptMethod()] public void SaveSearch(cnt strProp) { } 其中cnt是班级。 当我使用ajax调用来调用它时。where cnt is the class.When i calling this using ajax call like.var strArray = { cntName : "1", cntEmail : "2", cntMsg : "3" }$.ajax({ url: '/getproductsservice.asmx/SaveSearch', method: 'POST', data: { strProp : strArray}, contentType: 'application/json; charset=utf-8', success: function (data) { var showMsg = '' alert(showMsg); }, error: function (data) { alert('Save Search Failed'); } }); 运行时,我得到了一个例外,说明SaveSearch服务方法名称无效。 但是如果我用像string或int这样的原始数据类型替换参数它运行良好。问题在于对象类型(列表或对象等)。 如果我使用原始类型,它仅在ajax内容类型为content /时才有效xml不使用content / json。如果我使用json类型获得另一个例外尝试使用GET请求调用方法\ u0027SaveSearch \ u0027,这不允许。 请帮忙解决这个问题。When running this, i got the exception stating that "SaveSearch Service method name is not valid".But if I replace the parameter with primitive data type like string or int it is working well. Problem is with the object types (list or object etc).And if I use the primitive type, it is working only if the ajax content type is "content/xml" not working with "content/json". If I use the json type getting another exception of "An attempt was made to call the method \u0027SaveSearch\u0027 using a GET request, which is not allowed."Kindly help to resolve this.推荐答案 运行时,我得到了一个例外,说明SaveSearch服务方法名称无效。 但是如果我用像string或int这样的原始数据类型替换参数它运行良好。问题在于对象类型(列表或对象等)。 如果我使用原始类型,它仅在ajax内容类型为content /时才有效xml不使用content / json。如果我使用json类型获得另一个例外尝试使用GET请求调用方法\ u0027SaveSearch \ u0027,这不允许。 请帮忙解决此问题。When running this, i got the exception stating that "SaveSearch Service method name is not valid".But if I replace the parameter with primitive data type like string or int it is working well. Problem is with the object types (list or object etc).And if I use the primitive type, it is working only if the ajax content type is "content/xml" not working with "content/json". If I use the json type getting another exception of "An attempt was made to call the method \u0027SaveSearch\u0027 using a GET request, which is not allowed."Kindly help to resolve this.var strArray = { cntName : "1", cntEmail : "2", cntMsg : "3" }var input = { 'strProp' : strArray }; 这篇关于出现问题“服务方法名称无效”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 22:28