Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
VB
<WebMethod()> _
   Public Function GetAllItems(ByVal AgencyId As Integer) As List(Of Item)
       Return InventoryManager.GetAllItems()
   End Function

and my
VB
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

JavaScript
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
Posted
Updated 8-Oct-12 10:00am
v2
Comments
I.explore.code 8-Oct-12 16:02pm    
do you get any errors?
Ganesh KP 9-Oct-12 1:36am    
Noah I didnot get any errors it is just saying Success, but the db has not updated in my service.
Al Moje 9-Oct-12 1:45am    
Hi,
Have you Serialized your Entity Class?

Example:
[Serializable]
public class Inventory
{
//...
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900