WCF strange behaviour

后端 未结 1 1293
梦谈多话
梦谈多话 2020-12-21 23:34

I got this when I consume a webservice:

Operation \'Login\' of contract \'IServices\' specifies multiple request body parameters to be serialized with

相关标签:
1条回答
  • 2020-12-21 23:52

    First I'm not sure why you are using GET operation for login, you should use POST right? Next you have defined two parameters in the UriTemplate but the method contain only one. I would suggest you to use a class as parameter and instead of returning string you could return a model as well.

    public class LoginModel
    {
       public string username { get; set; }
       public string password { get; set; }
    }
    
    public class Result
    {
       public bool success { get; set; }
       public string error { get; set; }
    }
    
    [WebInvoke(Method = "POST",
    RequestFormat = WebMessageFormat.Json,
    ResponseFormat = WebMessageFormat.Json,
    UriTemplate = "/LogIn")]
    public Result login(LoginModel loginModel)
    
    0 讨论(0)
提交回复
热议问题