Click here to Skip to main content
13,000,017 members (46,272 online)
Rate this:
Please Sign up or sign in to vote.
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
<WebMethod()> _
   Public Function GetAllItems(ByVal AgencyId As Integer) As List(Of Item)
       Return InventoryManager.GetAllItems()
   End Function

and my
 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);
                    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?

Posted 8-Oct-12 9:23am
Updated 8-Oct-12 10:00am
gladiatron 8-Oct-12 16:02pm
do you get any errors?
Ganeshcse 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
Have you Serialized your Entity Class?

public class Inventory

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100