If you are using a WCF (Web) Service in client application and dealing with large data, at some point you may come across an error message:

{"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."}

 

Solutions:

Open your web.config or App.Config file at client and change the values in your bindings. Change the value of following configurations from 65536 (default) to 2147483647. That means it will allow up to 2GB.

<wsHttpBinding>
    <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
     openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
     bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
     maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text"
     textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
      maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
     <reliableSession ordered="true" inactivityTimeout="00:10:00"
      enabled="false" />
     <security mode="Message">
      <transport clientCredentialType="Windows" proxyCredentialType="None"
       realm="" />
      <message clientCredentialType="Windows" negotiateServiceCredential="true"
       algorithmSuite="Default" establishSecurityContext="true" />
     </security>
    </binding>
   </wsHttpBinding>
Signature

REST, or Representational State Transfer, is a type of Web service that is rapidly gaining in popularity. So you might ask yourself what the difference is between RESTful services and custom Web services, and why you might choose one type over the other. The key difference between the two types is that REST services are resource-centric while custom services are operation-centric. With REST, you divide your data into resources, give each resource a URL, and implement standard operations on those resources that allow creation, retrieval, update, and deletion (CRUD). With custom services, you can implement any arbitrary method, which means that the focus is on the operations rather than the resources, and those operations can be tailored to the specific needs of your application.


Some services fit very naturally into the REST model—usually when the resources are obvious and much of the service involves management of those resources. Exchange Server, for instance, has a REST API for organizing e-mail and calendar items. Similarly, there are photo-sharing Web sites on the Internet that expose REST APIs. In other cases, the services less clearly match REST operations, but can still be made to fit. Sending e-mail, for example, can be accomplished by adding a resource to an outbox folder. This is not the way you would most naturally think about sending e-mail, but it is not too much of a stretch.


In other cases, though, REST operations just do not fit well. Creating a resource in order to initiate a workflow that drives monthly payroll check printing, for example, would be much less natural than having a specific method for that purpose.


If you can fit your service into the constraints of REST, doing so will buy you a lot of advantages. ADO.NET Data Services in combination with the Entity Framework makes it easy to create both RESTful services and clients to work with them. The framework can provide more functionality to RESTful services automatically because the services are constrained to follow a specific pattern. In addition, RESTful services have a very broad reach because they are so simple and interoperable. They work especially well when you do not know in advance who the clients might be. Finally, REST can be made to scale to handle very large volumes of operations.


For many applications, the constraints of REST are just too much. Sometimes the domain does not divide clearly into a single pattern of resources or the operations involve multiple resources at once. Sometimes the user actions and business logic around them do not map well to RESTful operations, or more precise control is required than can fit into those operations. In these cases, custom services are the way to go.


You can always build an application that has a mix of REST and custom services. Often the ideal solution for an application is a mixture of both.

Source: MSDN Magazine Jun 2009

Signature

In this post, the web service created in Part 1 will be consumed into a web page through Server Side Web Service Integration, Client Side SOAP XML HTTP Post, HTTP Form Post and Get. Following are the steps.

1.       Publish your ASMX Web Service on your local machine under IIS 5.1/6.0/7.0, in this example my published web service is located at my local machine:  http://vishwa/examplewebservice/customerwebservice.asmx
2.       Create a Web Site in Visual Studio 2008/5
3.       Add a Page called CustomerWebServiceTest.aspx, it will automatically added a code behind page CustomerWebServiceTest.aspx.vb
4.       Right Click on your Web Site Project and Add Web Reference by adding the published web service URL, give a local name to this Web Service Reference, in this example I named CustomerWebService.
5.       Add the following code in the  Page
 
CustomerWebServiceTest.aspx : Add following code in this page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CustomerWebServiceTest.aspx.vb" Inherits="CustomerWebServiceTest" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test ASMX Web Service</title>
</head>
<body>
 
    <h2>Test Customer ASMX Web Service</h2>
  
    <form id="frmCustServer" runat="server">
        <div>
        <table>
         <tr>
            <td colspan="2"><b>Through Server Side Web Service Reference</b></td>
        </tr>
        <tr>
            <td >Customer ID :</td>
            <td><asp:TextBox ID="txtCustID" runat="server" Text="12345"></asp:TextBox></td>
        </tr>    
        <tr>
            <td>Customer Name :</td>
        <td>
            <asp:TextBox ID="txtCustName" runat="server" Text="Joe Smith"></asp:TextBox>
        </td>
        </tr>
        <tr>
            <td>Customer DOB (yyyy-mm-dd):</td>
            <td><asp:TextBox ID="txtCustDOB" runat="server" Text="1980-08-08"></asp:TextBox></td>
        </tr>
        <tr>
            <td>Customer Address:</td>
            <td><asp:TextBox ID="txtCustAddress" runat="server" Text="unknown"></asp:TextBox></td>
        </tr>
          <tr>
            <td><asp:Button ID="btnGetCustomer" runat="server" Text="Get Customer" /></td>
            <td><asp:Button ID="btnAddCustomer" runat="server" Text="Add Customer" /></td>
        </tr>
        <tr>
            <td> <asp:Button ID="btnUpdateCustomer" runat="server" Text="Update Customer" /></td>
            <td><asp:Button ID="btnDeleteCustomer" runat="server" Text="Delete Customer" /></td>
        </tr>
        <tr>
            <td>
            <asp:Button id="btnGetCustomers" runat="server" Text="Get All Customers"/></td>
            <td><asp:Label ID="lblStatus" runat="server" Text="Status"
                    ForeColor="#CC3300" style="font-weight: 700"></asp:Label></td>
        </tr>
        </table>
   </div>      
  
    </form>
   
    <br />
    <form id="frmCustomerS" method="post" action="CustomerWebServiceTest.aspx">
    <div>   
        <table>
        <tr><td colspan="2"><b>Through Client Side SOAP/XML HTTP POST</b></td></tr>
        <tr><td>Customer ID :</td><td><input name="ID" id="ID" type="text" value="12345" /> </td></tr>
        <tr><td>Customer Name :</td><td><input name="Name" id="Name" type="text" value="Chris Clark" /> </td></tr>
        <tr><td>Customer DOB (yyyy-mm-dd):</td><td><input name="DOB" id="DOB" type="text" value="1980-08-08"/> </td></tr>
        <tr><td>Customer Address:</td><td><input name="Address" id="Address" type="text" value="unknown"/> </td></tr>
         <tr>
            <td><input type="button" name="btnGetCustomer" value="Get Customer" onclick="GetCustomerSOAP()" /></td>
            <td><input type="button" name="btnAddCustomer" value="Add Customer" onclick="AddCustomerSOAP()" /></td>
        </tr>
         <tr>
            <td><input type="button" name="btnUpdateCustomerS" value="Update Customer" onclick="UpdateCustomerSOAP()" /></td>
            <td><input type="button" name="btnDeleteCustomerS" value="Delete Customer" onclick="DeleteCustomerSOAP()"/></td>
        </tr>    
        <tr>
            <td colspan="2"><input type="button" name="btnGetCustomersS" value="Get All Customers" onclick="GetCustomersSOAP()"/></td>
        </tr>  
        </table>
    </div>  
    </form>
   
   
     <br />
    <form id="frmCustomerPost" method="post" action="http://vishwa/examplewebservice/customerwebservice.asmx/GetCustomer">
    <div>   
        <table>
        <tr><td colspan="2"><b>Through Client Side HTML Form HTTP POST</b></td></tr>
        <tr><td>Customer ID :</td><td><input name="ID" type="text" value="969225896" /> </td></tr>
         <tr>
            <td colspan="2"><input type="submit" name="btnGetAllCustomers" value="Get Customer"/></td>
        </tr>  
        </table>
    </div>  
    </form>
   
    <form id="frmCustomerGet" method="get" action="http://vishwa/examplewebservice/customerwebservice.asmx/GetCustomer">
    <div>   
        <table>
        <tr><td colspan="2"><b>Through Client Side HTML Form HTTP GET</b></td></tr>
        <tr><td>Customer ID :</td><td><input name="ID" type="text" value="969225896" /> </td></tr>
         <tr>
            <td colspan="2"><input type="submit" name="btnGetAllCustomers" value="Get Customer"/></td>
        </tr>  
        </table>
    </div>  
    </form>
   
    <script type="text/javascript" language="javascript">
          
        var urlToPost = "http://vishwa/examplewebservice/customerwebservice.asmx";
        var fixedSoapAction = "http://webservices.vishwamohan.net/";
        var serviceNameSpace = "\"http://webservices.vishwamohan.net\"";
       
        var d = new Date();
       
        function getFullDate()
            {
            if (d.getDate()<10)
                return "0" + d.getDate();
            else
                return d.getDate();
             }
            
         function getFullMonth()
            {
            if (d.getMonth()<10)
                return "0" + parseInt(d.getMonth()+1);
            else
                return parseInt(d.getMonth()+1);
             }  
       
        var curdate = d.getFullYear() + "-" + getFullMonth()+ "-" + getFullDate();
         function GetCustomerSOAP()
            {
              var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                  dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                  dataText = dataText + " <soap:Body><GetCustomer xmlns=" + serviceNameSpace + ">";
                  dataText += " <ID>" + frmCustomerS.ID.value + "</ID>";
                  dataText += " </GetCustomer>";
                  dataText += " </soap:Body></soap:Envelope>";
                  alert(dataText);
                 
              var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");                 
                  xmlHttp.open("POST", urlToPost,false);              
                  xmlHttp.setRequestHeader("Content-Type", "text/xml");
                  xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"GetCustomer");
                  xmlHttp.send(dataText);
                  alert(xmlHttp.responseText);
            }
           
            function GetCustomersSOAP()
            {
              var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                  dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                  dataText = dataText + " <soap:Body><GetCustomers xmlns=" + serviceNameSpace + ">";
                  dataText += " </GetCustomers>";
                  dataText += " </soap:Body></soap:Envelope>";
                  alert(dataText);
              
              var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");                 
                  xmlHttp.open("POST", urlToPost,false);              
                  xmlHttp.setRequestHeader("Content-Type", "text/xml");
                  xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"GetCustomers");
                  xmlHttp.send(dataText);
                  alert(xmlHttp.responseText);
            }
   
        function AddCustomerSOAP()
            {
               var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                  dataText += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                  dataText += " <soap:Body><AddCustomer xmlns=" + serviceNameSpace + "> <CustomerRecord>";
                  dataText += " <ID>0</ID><Name>" + frmCustomerS.Name.value + "</Name><DOB>" + frmCustomerS.DOB.value +"</DOB>" ;
                  dataText += " <Address>" + frmCustomerS.Address.value + "</Address>";
                  dataText += " <DateCreated>" + curdate + "</DateCreated><DateModified>" + curdate + "</DateModified>" ;
                  dataText += " </CustomerRecord></AddCustomer>"
                  dataText += " </soap:Body></soap:Envelope>";
                  alert(dataText);
             
              var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");                 
                  xmlHttp.open("POST", urlToPost,false);              
                  xmlHttp.setRequestHeader("Content-Type", "text/xml");
                  xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"AddCustomer");
                  xmlHttp.send(dataText);
                  alert(xmlHttp.responseText);
            }
           
            function UpdateCustomerSOAP()
            {
               var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                  dataText += " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                  dataText += " <soap:Body><UpdateCustomer xmlns=" + serviceNameSpace + "> <CustomerRecord>";
                  dataText += " <ID>" + frmCustomerS.ID.value + "</ID><Name>" + frmCustomerS.Name.value + "</Name><DOB>" + frmCustomerS.DOB.value +"</DOB>" ;
                  dataText += " <Address>" + frmCustomerS.Address.value + "</Address>";
                  dataText += " <DateCreated>" + curdate + "</DateCreated><DateModified>" + curdate + "</DateModified>" ;
                  dataText += " </CustomerRecord></UpdateCustomer>"
                  dataText += " </soap:Body></soap:Envelope>";
                  alert(dataText);
             
              var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");                 
                  xmlHttp.open("POST", urlToPost,false);              
                  xmlHttp.setRequestHeader("Content-Type", "text/xml");
                  xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"UpdateCustomer");
                  xmlHttp.send(dataText);
                  alert(xmlHttp.responseText);
            }
           
           
             function DeleteCustomerSOAP()
            {
              var dataText = "<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                  dataText = dataText + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                  dataText = dataText + " <soap:Body><DeleteCustomer xmlns=" + serviceNameSpace + ">";
                  dataText += " <ID>" + frmCustomerS.ID.value + "</ID>";
                  dataText += " </DeleteCustomer>";
                  dataText += " </soap:Body></soap:Envelope>";
                  alert(dataText);
             
              var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");                 
                  xmlHttp.open("POST", urlToPost,false);              
                  xmlHttp.setRequestHeader("Content-Type", "text/xml");
                  xmlHttp.setRequestHeader("SOAPAction", fixedSoapAction +"DeleteCustomer");
                  xmlHttp.send(dataText);
                  alert(xmlHttp.responseText);
            }
   
    </script>
   
    </body>
</html>
  
CustomerWebServiceTest.aspx.vb : Add following code in code behind
 
Partial Class CustomerWebServiceTest
    Inherits System.Web.UI.Page
 
    Protected Sub btnGetCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetCustomer.Click
        Dim webSrv As New CustomerWebService.CustomerWebService
        Dim cust As CustomerWebService.Customer = webSrv.GetCustomer(CInt(Me.txtCustID.Text))
        If cust.ID > 0 Then
            Me.txtCustID.Text = cust.ID
            Me.txtCustName.Text = cust.Name
            Me.txtCustDOB.Text = cust.DOB
            Me.txtCustAddress.Text = cust.Address
            Me.lblStatus.Text = "Customer found."
        Else
            Me.lblStatus.Text = "Customer not found."
            Me.txtCustName.Text = ""
            Me.txtCustDOB.Text = ""
            Me.txtCustAddress.Text = ""
           
        End If
    End Sub
 
    Protected Sub btnAddCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddCustomer.Click
        Dim webSrv As New CustomerWebService.CustomerWebService
        Dim cust As New CustomerWebService.Customer
        cust.Name = Me.txtCustName.Text
        cust.Address = Me.txtCustAddress.Text
        cust.DOB = CDate(Me.txtCustDOB.Text)
        Dim rtn As Integer = webSrv.AddCustomer(cust)
        Me.txtCustID.Text = rtn.ToString
        lblStatus.Text = "Cust ID: " & rtn.ToString
    End Sub
 
    Protected Sub btnUpdateCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpdateCustomer.Click
        Dim webSrv As New CustomerWebService.CustomerWebService
        Dim cust As New CustomerWebService.Customer
        cust.ID = CInt(Me.txtCustID.Text)
        cust.Name = Me.txtCustName.Text
        cust.DOB = CDate(Me.txtCustDOB.Text)
        cust.Address = Me.txtCustAddress.Text
        Dim rtn As Boolean = webSrv.UpdateCustomer(cust)
        lblStatus.Text = "Update Status is : " & rtn.ToString
    End Sub
 
    Protected Sub btnDeleteCustomer_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeleteCustomer.Click
        Dim webSrv As New CustomerWebService.CustomerWebService
        Dim rtn As Boolean = webSrv.DeleteCustomer(CInt(Me.txtCustID.Text))
        lblStatus.Text = "Delete Status is : " & rtn.ToString
    End Sub
 
    Protected Sub btnGetCustomers_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetCustomers.Click
        Dim webSrv As New CustomerWebService.CustomerWebService
        Dim custArr() As CustomerWebService.Customer
        custArr = webSrv.GetCustomers()
 
        For Each cust As CustomerWebService.Customer In custArr
            Response.Write("ID: " & cust.ID.ToString & " Name: " & cust.Name & "<br/>")
        Next
        lblStatus.Text = "No of Customer Records found: " & custArr.Length.ToString
    End Sub
End Class
 
 
Now Run your website and test your service, you should be able to test each process. The page at run time looks like…
 
Signature

You must be wondering, that in WCF era ASMX Web Service! I wrote the first one 5 years ago and now trying to move them to WCF Service, but lot of companies have not even adopted the web service and some have only started adopting it recently, and now they realized that a new era has come. I will discuss my experiments & experiences with WCF in later posts. However, I would like to post a simple Customer ASMX Web Service and then consume it by a ASP.NET Web Page via Server Side and then Client Side using direct SOAP based XML through HTTP Post. Later, I will create a similar WCF Service with exactly same methods and will access the data exactly same way. Remember this is not a simple HelloWorld Example, this Web Service deals with primitive data type as well as complex one. How far you would like to dive deep into it, will be up to you.

          In order to keep the example sweet and simple and close to real world, I will be using a Customers XML data file and will perform CRUD operations.  I created this project using Visual Studio 2008 and wrote code using VB.NET.

           You can also use Visual Studio 2005 for this project. 

This project basically contains 5 file, you can create them in following order.
1.       Web.Config
2.       Customer.vb - Customer class
3.       ServiceHelper.VB – Collection of CRUD Methods
4.       CustomerWebService.asmx – ASMX Web Service Page
5.       CustomerWebService.asmx.vb – Code behind file of the .asmx file
 
My Project Name is – Vishwa.Example.WebService
 
Web.Config
If you are planning to deploy this web service for HTTP GET and POST uses, add the following lines under <system.web> section. By default they will only work if you are running locally.
<webServices>
                                    <protocols>
                                              <add name="HttpPost" />
                                              <add name="HttpGet" />
                                     </protocols>
                         </webServices>
 
Customer.vb - Add this class in your project with following code. This class is a Data Transfer Object.
 
Namespace Example.WebService
    Public Class Customer
 
        <System.Xml.Serialization.XmlElement(ElementName:="ID", Order:=0)> _
        Public CustID As Integer = 0
 
        <System.Xml.Serialization.XmlElement(ElementName:="Name", Order:=1)> _
        Public CustName As String = String.Empty
 
        <System.Xml.Serialization.XmlElement(ElementName:="DOB", Order:=2)> _
        Public CustDOB As DateTime = DateTime.MinValue
 
        <System.Xml.Serialization.XmlElement(ElementName:="Address", Order:=3)> _
        Public CustAddress As String = String.Empty
 
        <System.Xml.Serialization.XmlElement(ElementName:="DateCreated", Order:=4)> _
        Public DateCreated As DateTime = DateTime.Now
 
 
        <System.Xml.Serialization.XmlElement(ElementName:="DateModified", Order:=5)> _
        Public DateModified As DateTime = DateTime.Now
 
        Public Sub New()
 
        End Sub
 
    End Class
End Namespace
ServiceHelper.vb - Add this class now with following code. Please note that I am using a Customer Business Object, which I created in my earlier post.
Imports Vishwa.Example.Business
 
Namespace Example.WebService
    Public NotInheritable Class ServiceHelper
 
        Private Shared instance As New ServiceHelper
        Private Shared  bizObj As New CustomerBiz
        Private Sub New()
 
        EndSub
 
        Friend Shared Function GetCustomerData(ByVal ID AsInteger) As Customer
            Dim bizCustomer As CustomerBiz = Nothing
            bizCustomer = bizObj.GetCustomer(ID)
            Return GetCustomerDataFromBizCustomer(bizCustomer)
        End Function
 
        Friend Shared Function GetCustomersData() As List(Of Customer)
            Dim customers AsNew List(Of Customer)
            Dim bizCustomers AsNew List(Of CustomerBiz)
            bizCustomers = bizObj.GetCustomers()
 
            ForEach bizCustRec As CustomerBiz In bizCustomers
                customers.Add(GetCustomerDataFromBizCustomer(bizCustRec))
            Next
            Return customers
 
        End Function
 
        Friend Shared Function AddCustomerData(ByVal custRecord As Customer) As Integer
            Return bizObj.AddCustomer(custRecord.CustName, custRecord.CustDOB, custRecord.CustAddress)
        End Function
 
        Friend Shared Function UpdateCustomerData(ByVal custRecord As Customer) As Boolean
            Return bizObj.UpdateCustomer(custRecord.CustID, custRecord.CustName, custRecord.CustDOB, custRecord.CustAddress)
        End Function
 
        Friend Shared Function DeleteCustomerData(ByVal ID AsInteger) As Boolean
            Return bizObj.DeleteCustomer(ID)
        End Function
 
        Private Shared Function GetCustomerDataFromBizCustomer(ByVal bizCust As CustomerBiz) As Customer
            Dim custRecord AsNew Customer
            If Not bizCust Is Nothing AndAlso bizCust.CustID > 0 Then
                custRecord.CustID = bizCust.CustID
                custRecord.CustName = bizCust.CustName
                custRecord.CustDOB = bizCust.CustDOB
                custRecord.CustAddress = bizCust.CustAddress
                custRecord.DateCreated = bizCust.DateCreated
                custRecord.DateModified = bizCust.DateModified
            End If
            Return custRecord
        End Function
 
    End Class
End Namespace
 CustomerWebService.asmx – Add this ASMX file, a Code behind will be added by default. The markup inside CustomerWebService.asmx will looks like
 
<%@ WebService Language="VB" CodeBehind="CustomerWebService.asmx.vb" Class="Vishwa.Example.WebService.CustomerWebService" %>


CustomerWebService.asmx.vb Add following code in this file
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
 
Namespace Example.WebService
    <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Name:="CustomerWebService", Namespace:="http://webservices.vishwamohan.net", _
                                    Description:="Customer ASMX Web Service.")> _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
    <ToolboxItem(False)> _
    Public Class CustomerWebService
        Inherits System.Web.Services.WebService
 
        <WebMethod(Description:="Gets a customer record on customer ID.")> _
        Public Function GetCustomer(ByVal ID As Integer) As Customer
            Return ServiceHelper.GetCustomerData(ID)
        End Function
 
        <WebMethod(Description:="Gets all customer record.")> _
        Public Function GetCustomers() As List(Of Customer)
            Return ServiceHelper.GetCustomersData()
        End Function
 
        <WebMethod(Description:="Adds a customer record and returns customer ID.")> _
        Public Function AddCustomer(ByVal CustomerRecord As Customer) As Integer
            Return ServiceHelper.AddCustomerData(CustomerRecord)
        End Function
 
        <WebMethod(Description:="Deletes a customer record on customer ID.")> _
        Public Function DeleteCustomer(ByVal ID As Integer) As Boolean
            Return ServiceHelper.DeleteCustomerData(ID)
        End Function
 
        <WebMethod(Description:="Updates a customer record.")> _
        Public Function UpdateCustomer(ByVal CustomerRecord As Customer) As Boolean
            Return ServiceHelper.UpdateCustomerData(CustomerRecord)
        End Function
    End Class
End Namespace
 
You are done!
Now you compile the project and run. You should be able to see following 5 web methods.
In next post I will consume these methods through a web page via direct web service integration in project as well as through SOAP XML HTTP Post.
Signature

About Me

Me Hello,my name is Vishwa Mohan Kumar.
I am a Software Architect. This blog is result of my experiments.

Flickr Photos

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Recent Comments

Comment RSS

Live Traffic Feed