I have a c# asmx web service code like below.
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void getPolicyDetails(string CustId, string PolicyType)
{
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Clear();
Context.Response.ContentType = "application/json";
clsPolicy data = new clsPolicy();
try
{
string policyTxt = "";
//get PolicyTxt from Database
data.Message = policyTxt.ToString();
}
catch (Exception ex)
{
}
Context.Response.Write(js.Serialize(data));
}
Now, I am trying to consume this web service in asp.net. This web-service is already being used in my android project successfully.
When I try to use call it via javascript, it gives me a 500 - Internal server error. Below is my Javascript code.
function getPolicy(policyType) {
$.ajax({
type: "POST",
url: "http://myurl/productsearch.asmx/getPolicyDetails",
data: '{CustId: 106206,PolicyType: "' + policyType + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
alert(response.d);
}
What could be the problem?