开发者

Jquery/C# Making a webService call errors out: cannot be serialized because it does not have a parameterless constructor

开发者 https://www.devze.com 2022-12-21 14:26 出处:网络
Here\'s my call: CallMfttService(\"ServiceLayer/FieldingManager.asmx/GetUICs\",null, SetUicValues); Here\'s the WebMethod:

Here's my call:

CallMfttService("ServiceLayer/FieldingManager.asmx/GetUICs",null, SetUicValues);

Here's the WebMethod:

[WebMethod]
[ScriptMethod]
public List<string> GetUICs()
{
    UserManager user = new UserManager();
    var currentUser = user.GetUser(Security.FieldingToolPrincipal.Current.Identity.Name);
    List<string> uics = new List<string>();
    uics = Data.FieldingManager.SelectUicByJpm(currentUser.Organization);

    return uics;
}

I'm not exactly sure what the problem is.. I know it obviously doesn't like sending no paramters..I really don't know thou开发者_运维技巧gh.


The problem is most likely this:

Data.FieldingManager.SelectUicByJpm(currentUser.Organization);

The object you're returning, "uics", probably doesn't have a blank constructor. That is, a new with no parameters:

new UicObject();

Giving it one should fix your problem.


I found out the I need to send empty braces to the method.

CallMfttService("ServiceLayer/FieldingManager.asmx/GetUICs", "{}", SetUicValues);

the "{}" fixed the issue.. thanks for the replies


Try replacing null with new object[0] in your call:

CallMfttService("ServiceLayer/FieldingManager.asmx/GetUICs", new object[0], SetUicValues);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号