I'm getting an error Internal Server Error 500. For this problem I've tried everything but still unable to figure it out what is the real problem
My Web Service Code:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class CustomerDetails : System.Web.Services.WebService
{
[WebMethod]
public static List<CustomerDetailsEnity> fetchCustomerDetails(string branchCode, string customerCode)
{
operationMySql mysql = new operationMySql();
DataSet ds = new DataSet();
List<CustomerDetailsEnity> customerDetails = new List<CustomerDetailsEnity>();
try
{
string query = @"select Distinct ifnull(consignor_customer_code,consignor_code)
consinr_code, Concat(consignor_city,'-',consignor_name) consignor_name,
consignor_address_1, consignor_address_2, consignor_city, pincode, email,
, consignor_contact_person, GST_No from table1 where
branch_code='" + branchCode + "' and customer_code='" + customerCode + "' "+@"
Order by consignor_city,consignor_name";
string constr = mysql.ConnectionString;
using (MySqlConnection con = new MySqlConnection(constr))
{
using (MySqlDataAdapter ad = new MySqlDataAdapter(query, con))
{
ad.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
customerDetails.Add(new CustomerDetailsEnity
{
consignorCode = dr["consinr_code"].ToString(),
customerName = dr["consignor_name"].ToString(),
address1 = dr["consignor_address_1"].ToString(),
address2 = dr["consignor_address_2"].ToString(),
City = dr["consignor_city"].ToString(),
email = dr["email"].ToString(),
mobile = dr["consignor_contact_person"].ToString(),
contactPerson = dr["consignor_contact_person"].ToString(),
GSTN = dr["GST_No"].ToString()
});
}
}
}
}
}
catch(Exception ex)
{
}
return customerDetails;
}
public class CustomerDetailsEnity
{
public string consignorCode { get; set; }
public string customerName { get; set; }
public string address1 { get; set; }
public string address2 { get; set; }
public string City { get; set; }
public string pinCode { get; set; }
public string email { get; set; }
public string mobile { get; set; }
public string contactPerson { get; set; }
public string GSTN { get; set; }
}
}
My Ajax call:
<script type="text/javascript">
$(function () {
$("#ddl_CodeNameCust").change(function () {
$.ajax({
type: "POST",
url: "Services/CustomerDetails.asmx/fetchCustomerDetails",
dataType: "Json",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ branchCode: "PTPC", customerCode: "1000001" }),
success: function (Result) {
Result = Result.d;
},
error: function (Result) {
alert(Result.statusText);
}
})
});
});
</script>