JQuery :: Ajax Unable To Retrieve Data From Wcf Service
Feb 16, 2011
i am running with an unfamilier issue with jquery ajax and wcf service . i have created a simple wcf service and trying to show it on a asp.net label... the wcf service just returns a string which has to b shown on a label. the url has been set on jquery ajax url to call the wcf service using rest. but somehow i am not getting the desired thing done . the ajax cannot retrieve the data from the wcf service , here are the code snippets.
The Ajax Portion in default.aspx :
[Code]....
The Service Contract for WCF :
[Code]....
The implemented Method :
[Code]....
and the Web.Config :
[Code]....
can someone figure out here i am going wrong .... that the ajax is unable to retrieve the data from the above wcf Service .. its just a very basic and simple one .. but unable to figure out the Real Prblem.
I am using ASP.Net 3.5. I have fiiled dropdown list in javascript using ajax service but unable to get its selected value in button click event on server side.
I am new to WCF, I was using web service asmx before. I have trouble on making my wcf JSON ajax service work through http like asmx.Could you help me see what wrong in my code?My WCF services are defined in my website application folder. My aim is to call this service in my aspx page java-script code and return complex object back as JSON to my javascript. I have no problem on doing this through classic asmx web service.
When I try to test it through my browser by type this in the URL , URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc/GetAll. it return "Method not allowed."
But if I type just this URL-http://localhost:3849/WebServices/Account/WCFCompanyService.svc, it return this:
WCFCompanyService Service
You have created a service.To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
This will generate a configuration file and a code file that contains the client class. Add the two files to your client application and use the generated client class to call the Service. For example:
C#
class Test { static void Main() { HelloClient client = new HelloClient();
I'm not able to call a service using the scriptmanager and javascript. But when I include the service into the project i call it. but when i seperate it in another project. I'm not able to call.
Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. make sure the user has a local user profile on the computer. The connection will be closed.
After I formated my system, When I run my website on local IIS databases, aspnetdb.mdf don't seem to work. But works fine on local Cassini (VS).
But this problem is only with one of my new website , rest everything work fine.
Does it have anything to do with SQL Managment Studio? I din't take any backup of master database and all.
I am using asp.net 3.5. I filled dropdown list in javascript using ajax service but unable to get its selected value in button click event on server side.
i was wondoring which thing is better from below two... first one- retrive data by creating webservice second one- create database connection from code behind call storeprocedure and retive data
I have to retrieve the data from the web service and this data should be kept in process's memory and use it where needed.Do not like to call web service every time.Is there any method to do this?
i am still stumped with this operation: i am trying to retrieve a GridView selected row data..here is my code.. the commented part that gives me the selectedindex works just fine....but the one giving the selected row cell value does't work and there is no error.. The update operation is done successfully...weired. i need to assigned selected row cells values to variables ..do some calculations and then re-assign the result calculation to cell[9]..
I need to retirve data from two tables...when i click a value in dropdown list, i need to retrieve values from two tables based on that id( which i have selected in dropdown)..so when i have written query ( "Select assign_issue.issue_assigned_to, assign_issue.created_on,assign_issue.last_Date, issue_register.issue_desc,issue_register.issue_Priority from assign_issue INNER JOIN Issue_register ON assign_Issue.Issue_ID = issue_register.Issue_ID where issue_register = '" + ddlissueid.selecteditem.text + "'")..query is executing ..when it comes to dr = cmd.executereader()..Dr is unable to read..it is showing false when i trace..unable to read into while loop.
I need to pass a customer id to get some data back for a customer from a webservice. I can't figure out how to get to the webservice, I have a breakpoint set in the webmethod but it's not being hit and the alert box is not popping up either. For a test I am just trying to show some value from the returned data in an alert box. Note I am just hard coding the customer id of 1001. The webmethod takes a parameter of string customerid.
[Code]....
Does some one know what's missing or how to debug this issue?
i got checkbox in gridview which put inside the itemtemplate. the problem is when i tick on the checkbox, the value for checked property still is a false value. Wat;s wrong?
If GridViewRDR1_Hidden.Rows.Count > 0 Then For Each row As GridViewRow In GridViewRDR1_Hidden.Rows Dim cb As CheckBox = CType(row.FindControl("chkstatus"), CheckBox ) If cb.Checked Then MsgBox("True") End If Next End If
I am trying to update the database with the edited data. However, it did not manage to read the edited data from the textbox. It returned the retrieve data that I have done in the Page_Load instead. Is there any part of the code that I have written wrongly? I did manage not to use <EditItemTemplate> in my past project and manage to update the database with the same logic.
<aspx> <!-- This DataList is created to view Personal Information --> <asp:DataList ID="personal_dl" runat="server"> <ItemTemplate> <table> <tr> <td style="width: 100px; text-align: left;"> <asp:Label ID="first_lbl" runat="server" ForeColor="Black" Font-Size="11px" Text="First:"></asp:Label></td> <td style="width: 350px"> <asp:TextBox ID="first_tb" runat="server" Width="341px" Font-Size="11px" Text='<%# Eval("FIRST") %>'> </asp:TextBox> </td> </tr> <tr> <td style="width: 100px; text-align: left"> <asp:Label ID="name_lbl" runat="server" Font-Size="11px" ForeColor="Black" Text="Name:"></asp:Label> </td> <td style="width: 350px"> <asp:TextBox ID="name_tb" runat="server" Width="341px" Font-Size="11px" Text='<%# Eval("NAME") %>'> </asp:TextBox> </td> </tr> <tr> <td style="width: 100px; text-align: left;"> <asp:Label ID="id_lbl" runat="server" ForeColor="Black" Font-Size="11px" Text="ID:"> </asp:Label> </td> <td style="width: 350px"> <asp:TextBox ID="id_tb" runat="server" Width="341px" Font-Size="11px" Text='<%# Eval("ID") %>'> </asp:TextBox> </td> </tr> <tr> <td style="width: 100px; text-align: left;"> <asp:Label ID="contact_lbl" runat="server" ForeColor="Black" Font-Size="11px" Text="Contact No.:"> </asp:Label> </td> <td style="width: 350px"> <asp:TextBox ID="contact_tb" runat="server" Width="341px" Font-Size="11px" Text='<%# Eval("TELEPHONE_HP") %>'> </asp:TextBox> </td> </tr> <tr> <td style="width: 100px; text-align: left;"> <asp:Label ID="add_lbl" runat="server" ForeColor="Black" Font-Size="11px" Text="Address:"> </asp:Label> </td> <td style="width: 350px"> <asp:TextBox ID="add_tb" runat="server" Width="341px" Font-Size="11px" Text='<%# Eval("ADDRESS") %>'> </asp:TextBox> </td> </tr> </table> </ItemTemplate> </asp:DataList> <br /> <div style="text-align: center; color: Red; width: 460px;"> <asp:Label ID="errorMsg_lbl" runat="server" /> <asp:Button ID="edit_btn" runat="server" Text="Update" /> <asp:Button ID="createBtn" runat="server" Text="Insert" /></div> <aspx.vb> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'display information in datalist Dim login As String = Session("login") Dim id As String = Session("id") bindDataList(personal_dl, getPersonalContent(login, id)) 'display necessary DataList personal_dl.Visible = True 'declare fields Dim i As Integer Dim first_tb, name_tb, id_tb, contact_tb, add_tb As New TextBox For i = 0 To personal_dl.Items.Count - 1 first_tb = personal_dl.Items(i).FindControl("first_tb") name_tb = personal_dl.Items(i).FindControl("name_tb") id_tb = personal_dl.Items(i).FindControl("id_tb") contact_tb = personal_dl.Items(i).FindControl("contact_tb") add_tb = personal_dl.Items(i).FindControl("add_tb") 'set fields as ReadOnly - cannot edit first_tb.ReadOnly = False name_tb.ReadOnly = False id_tb.ReadOnly = False contact_tb.ReadOnly = False add_tb.ReadOnly = False Next End Sub
Protected Sub edit_btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles edit_btn.Click 'declare fields Dim i As Integer Dim first_tb, name_tb, id_tb, contact_tb, add_tb As New TextBox Dim id As String = Session("id") For i = 0 To personal_dl.Items.Count - 1 first_tb = personal_dl.Items(i).FindControl("first_tb") name_tb = personal_dl.Items(i).FindControl("name_tb") id_tb = personal_dl.Items(i).FindControl("id_tb") contact_tb = personal_dl.Items(i).FindControl("contact_tb") add_tb = personal_dl.Items(i).FindControl("add_tb") Next Dim myConnection As OleDbConnection = dbConnection() Dim cmd As New OleDbCommand Dim sqlStatement As String Dim condition As String condition = "UPDATE staff " + _ "SET ((FIRST= @FIRST), (NAME = @NAME), (ID= @ID), (TELEPHONE_NO = @CONTACT_NO), (ADDRESS = @ADDRESS)) " + _ "WHERE (ID= @id)" sqlStatement = condition cmd.CommandText = sqlStatement cmd.CommandType = CommandType.Text cmd.Parameters.AddWithValue("@FIRST", first_tb) cmd.Parameters.AddWithValue("@NAME", name_tb) cmd.Parameters.AddWithValue("@ID", id_tb) cmd.Parameters.AddWithValue("@TELEPHONE_NO", contact_tb) cmd.Parameters.AddWithValue("@ADDRESS", add_tb) cmd.Parameters.AddWithValue("@ID", id) cmd.Connection = myConnection Try myConnection.Open() cmd.ExecuteNonQuery() Catch ex As Exception Finally If myConnection.State = ConnectionState.Open Then myConnection.Close() End If End Try 'display information in datalist Dim login As String = Session("login") bindDataList(personal_dl, getPersonalContent(login, id)) End Sub
[ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class Aja { [WebGet] [OperationContract] public string Hi() { return "hi world!"; } }
and I'm trying to do this: $.get('Aja.svc?method=Hi', function(d) { alert(d.d); }); In firebug I see that the result is HTTP Error 404.17 - Not Found The requested content appears to be script and will not be served by the static file handler. I use .net 3.5, jquery 1.4.4
I created a number of standard WCF Services (Service Contract and Host (svc) are in separate assemblies). I fired up a Web Site in IIS to host the Services (i.e., address is [URL]). Then in my Web Site project I added the reference. I am able to call the services normally. I am needed to call some of the services client side. Not sure if I should be looking at articles calling WCF services through AJAX, JQuery, or JSON enabled WCF Services. Some of the changes I made was adding the following to the Operation Contract:
I am attempting to call the service like this in javascript: wcfservices.SetFoo(string Id); Nothing is working. If it is idea or a better solution to call JSON enable, JQuery, etc.... I am willing to make any changes.
I am trying to call an asmx service using the jQuery ajax call-
[Code]....
I have double checked the url of the service and spelling/case of the name of the method as well as the parameters in the dataStr.
I still get the error-<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. review the following URL and make sure that it is spelled correctly.