Hi friends,
I have created a asmx web service.The service will interact with SQL Server database to Get, Insert and Update of some tables in my db.
I have one Service method called AddItem which takes a class object as parameter. with that parameter I am inserting the values into the database. In the same way I have another service method that Gets all the Items from db using the same class and returns the class object as the return type for my service.
Here is my sample AddItem() and GetAllItems() prototype
Collapse | Copy Code
<WebMethod()> _ Public Function GetAllItems(ByVal AgencyId As Integer) As List(Of Item) Return InventoryManager.GetAllItems() End Function
and my AddItem()
Public Function AddItem(ByVal ThisItem As Item) As Integer
Return InventoryManager.AddItem(ThisItem)
End Function
and I created a aspx application that has to consume that service. I have created web forms to display the items in my aspx application.
Everything is works fine like I am able to run the service and web application also.
I am consuming the service from Jquery ajax function.
To consume my service I have to host in IIS for that I have followd the steps menthiond in this site
Check Here[^]
while I run my web app I am unable to get the data from my service What probable I am missing? Whether I am gone in wrong way?
here is my Jquery code of calling the service from my web application
try {
var DTO = { "ThisItem": Item };
var ItemDetails = JSON.stringify(DTO);
alert(ItemDetails); $.ajax ({ type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://localhost/InventoryWebServicePub/InventoryService.asmx/AddItem",
data: ItemDetails, dataType: "json",
success: function () { alert("Success"); }, error: function () {
alert("Error Occured");
} }); } catch (err) {
alert("Error in Get Items " + err.Message);
}
Please any one could tell me, it seems that I have pasted a long matter its all that I need to tell exactly what I did?
Thanks
Ganesh