The complete error iam getting is
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <servicedebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <servicedebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Why iam gettig this error?
my Properties in this Project Used are
Properties set in my project are below
namespace EmployeeService
{
public class Employee
{
private int _Id;
private string _Name;
private string _Gender;
private DateTime _DateofBirth;
public int Id
{
get { return _Id; }
set { _Id = value; }
}
public string Name
{
set { _Name = value; }
get { return _Name; }
}
public string Gender
{
set { _Gender = value; }
get { return _Gender; }
}
public DateTime DateofBirth
{
set { _DateofBirth = value; }
get { return _DateofBirth; }
}
}
This is the service i have developed in my project
namespace EmployeeService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class EmployeeService : IEmployeeService
{
public Employee GetEmployee(int Id)
{
Employee objemp = new Employee();
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spGettblEmployeewcf", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter Idparameter = new SqlParameter();
Idparameter.ParameterName = "@Id";
Idparameter.Value = Id;
cmd.Parameters.Add(Idparameter);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
objemp.Id = Convert.ToInt32(dr["Id"]);
objemp.Name = dr["Name"].ToString();
objemp.Gender = dr["Gender"].ToString();
objemp.DateofBirth = Convert.ToDateTime(dr["DateofBirth"]);
}
}
return objemp;
}
public void SaveEmployee(Employee objemp)
{
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spInsertEmployeewcf", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter ParameterId = new SqlParameter()
{
Value = objemp.Id,
ParameterName = "@Id"
};
cmd.Parameters.Add(ParameterId);
SqlParameter ParameterName = new SqlParameter()
{
Value = objemp.Name,
ParameterName = "@Name"
};
cmd.Parameters.Add(ParameterName);
SqlParameter ParameterGender = new SqlParameter()
{
Value = objemp.Gender,
ParameterName = "@Gender"
};
cmd.Parameters.Add(ParameterGender);
SqlParameter ParameterDateofBirth = new SqlParameter()
{
Value = objemp.DateofBirth,
ParameterName = "@DateofBirth"
};
cmd.Parameters.Add(ParameterDateofBirth);
con.Open();
cmd.ExecuteNonQuery();
}
}
}
}
The Service Contract code is
namespace EmployeeService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface IEmployeeService
{
[OperationContract]
Employee GetEmployee(int Id);
[OperationContract]
void SaveEmployee(Employee objemp);
// TODO: Add your service operations here
}
// Use a data contract as illustrated in the sample below to add composite types to service operations
}
and i deployed the EmployeeService in iis and consuming the service in my web application the code is below
protected void btnsave_Click(object sender, EventArgs e)
{
EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient("basicHttpBinding");
EmployeeService.Employee employee = new EmployeeService.Employee();
employee.Id = Convert.ToInt32(txtid.Text);
employee.Name = txtname.Text;
employee.Gender = txtgender.Text;
employee.DateofBirth = Convert.ToDateTime(txtdob.Text);
client.SaveEmployee(employee);
}
protected void btnget_Click(object sender, EventArgs e)
{
EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient("basicHttpBinding");
EmployeeService.Employee employee = client.GetEmployee(Convert.ToInt32(txtid.Text));
txtname.Text = employee.Name;
txtgender.Text = employee.Gender;
txtdob.Text = employee.DateofBirth.ToShortDateString();
}
and when i am entering the details of employee Id,Name,Gender,DateofBirth and clicking save button iam getting the following error
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <servicedebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Code in web.config file in Webapplication(Client) is the following
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.diagnostics>
<sources>