TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Monica Priyadharshini
NA
103
4.8k
error in Web Service
Oct 26 2017 7:28 AM
Hi,
I have a gridview which display the list of student details from the database. I have used webservice in this. what is the problem here is, when i add this web service to the application the data of student is not fetched from the database , but it worked wel when i tried before adding the webservice. I dono what is the problem, Please help me to find out.
DAL:
public class StudentDALClass
{
string constring = System.Configuration.ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;
/// <summary>
/// Binding the Gridview
/// </summary>
/// <returns></returns>
public DataTable StudentGridBindDAL()
{
SqlConnection con = new SqlConnection(constring); ;
DataTable dt = new DataTable();
SqlDataAdapter dataAdapter;
SqlCommandBuilder commandBuilder;
try
{
con.Open();
dataAdapter = new SqlDataAdapter("spSelectStudentTable", con);
commandBuilder = new SqlCommandBuilder(dataAdapter);
dataAdapter.Fill(dt);
return dt;
}
catch (SqlException)
{
throw new Exception("Error Occurred in DB, Please try again later");
}
catch (NullReferenceException)
{
throw new Exception("Invalid data has been passed");
}
catch (FormatException)
{
throw new Exception("Iput string was not in a correct formate");
}
catch (IndexOutOfRangeException)
{
throw new Exception("Invaid input has been passed");
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (con.State == ConnectionState.Open)
{
con.Close();
}
}
}
}
BLL:
public class StudentBLLClass
{
StudentDALClass dal = new StudentDALClass();
/// <summary>
/// binding the student data to the grid view
/// </summary>
/// <returns></returns>
public DataTable StudnetBindBLL()
{
DataTable dt;
try
{
dt = dal.StudentGridBindDAL();
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
}
WEB Service :
[ServiceContract]
public interface IService1
{
[OperationContract]
DataTable StudnetBindService();
[OperationContract]
void AddStudentService(StudentEntityClass se);
[OperationContract]
void UpdateStudentService(StudentEntityClass se);
[OperationContract]
void DaleteStudentService(StudentEntityClass se);
}
//implementing interface
public class Service1 : IService1
{
StudentBLLClass bll = new StudentBLLClass();
public DataTable StudnetBindService()
{
DataTable dt;
dt = bll.StudnetBindBLL();
return dt;
}
public void AddStudentService(StudentEntityClass se)
{
bll.AddStudentBLL(se);
}
public void UpdateStudentService(StudentEntityClass se)
{
bll.UpdateStudentBLL(se);
}
public void DaleteStudentService(StudentEntityClass se)
{
bll.DaleteStudentBLL(se);
}
}
Code Behind:
StudentBLLClass bll = new StudentBLLClass();
StudentListServiceReference.Service1Client servicereference = new StudentListServiceReference.Service1Client();
/// <summary>
/// Displaying gridview in pageload
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
try
{
GridBind();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
}
EntityLayer:
public class StudentEntityClass
{
public int StudentId { get; set; }
public string StudentName { get; set; }
public string EmailId { get; set; }
public string PhoneNumber { get; set; }
public string City { get; set; }
}
UI Layer:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<h1>List Of Students</h1>
<div>
<asp:GridView ID="grdStudentList" runat="server" AutoGenerateColumns="False" Width="500px" Height="200px"
DataKeyNames="StudentID" ShowFooter="true" CellPadding="4" ForeColor="#333333" GridLines="None"
HorizontalAlign="Center" OnRowCancelingEdit="grdStudentList_RowCancelingEdit" OnRowEditing="grdStudentList_RowEditing"
OnRowUpdating="grdStudentList_RowUpdating" OnRowDeleting="grdStudentList_RowDeleting">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateField HeaderText="Student ID">
<ItemTemplate>
<asp:Label ID="lblStudentId" runat="server" Text='<%#Bind("StudentID") %>'>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtStudentID" runat="server" Width="180px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Student Name">
<ItemTemplate>
<asp:Label ID="lblStudentName" runat="server" Text='<%#Bind("StudentName") %>'>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditStudentName" runat="server" Text='<%#Bind("StudentName") %>'>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtStudentName" runat="server" Width="180px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email Id">
<ItemTemplate>
<asp:Label ID="lblEmailID" runat="server" Text='<%#Bind("EmailID") %>'>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditEmailID" runat="server" Text='<%#Bind("EmailID") %>'>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtEmailID" runat="server" Width="180px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Mobile Number">
<ItemTemplate>
<asp:Label ID="lblPhoneNumber" runat="server" Text='<%#Bind("PhoneNumber") %>'>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditPhoneNo" runat="server" Text='<%#Bind("PhoneNumber") %>'>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPhoneNo" runat="server" Width="180px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="lblCity" runat="server" Text='<%#Bind("City") %>'>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtEditCity" runat="server" Text='<%#Bind("City") %>'>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtCity" runat="server" Width="180px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Edit" Font-Bold="true" CommandName="Edit" Width="150px"/>
</ItemTemplate>
<EditItemTemplate>
<asp:Button ID="btnUpdate" runat="server" Text="Update" Font-Bold="true" CommandName="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" Font-Bold="true" CommandName="Cancel" />
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="btnAdd" runat="server" Text="Add" Width="150px" Font-Bold="true" CommandName="Add" OnClick="AddButtonClick" />
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnDelete" runat="server" Text="Delete" Font-Bold="true" CommandName="Delete" Width="150px" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
<RowStyle HorizontalAlign="Center"/>
</asp:GridView>
</div>
</form>
</body>
</html>
WEB CONFIG FILE:
<configuration>
<connectionStrings>
<add name="conStr" connectionString="Database=AdventureWorks2008;Server=CHV8LTDBNC01\LENTRACSDB2008;Integrated Security=False;UID=sqltrainer;PWD=Welcome123" providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Reply
Answers (
3
)
End point related
Android Studio, soap2 http request failed, http status : 404