我正在遇到这个错误:
我正在使用以下内容:
Operation 'Login' in contract 'Medicall' has a query variable named 'objLogin' of type 'Medicall_WCF.Medicall+clsLogin', but type 'Medicall_WCF.Medicall+clsLogin' is not convertible by 'QueryStringConverter'. Variables for UriTemplate query values must have types that can be converted by 'QueryStringConverter'.
我试图向我的WCF服务传递参数,但该服务甚至没有显示。
#region Methods
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public Int32 Login(clsLogin objLogin)
{
try
{
// TODO: Database query.
if (objLogin.username == "" & objLogin.password == "")
return 1;
else
return 0;
}
catch (Exception e)
{
// TODO: Handle exception error codes.
return -1;
}
}
#endregion
#region Classes
[DataContract(), KnownType(typeof(clsLogin))]
public class clsLogin
{
public string username;
public string password;
}
#endregion
我正在使用以下内容:
$.ajax({
url: "PATH_TO_SERVICE",
dataType: "jsonp",
type: 'post',
data: { 'objLogin': null },
crossDomain: true,
success: function (data) {
// TODO: Say hi to the user.
// TODO: Make the menu visible.
// TODO: Go to the home page.
alert(JSON.stringify(data));
},
failure: function (data) { app.showNotification('Lo sentimos, ha ocurrido un error.'); }
});
为了调用该服务,以前使用一个接收1个字符串参数的服务是有效的。 如何接收该对象?