Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET ASMX
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
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
Posted 8-Oct-12 10:23am
Ganeshcse2.3K
Edited 8-Oct-12 11:00am
(no name)7.9K
v2
Comments
gladiatron at 8-Oct-12 16:02pm
   
do you get any errors?
Ganeshcse at 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 at 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)

  Print Answers RSS
0 OriginalGriff 410
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 235
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 8 Oct 2012
Copyright © CodeProject, 1999-2014
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