Consumers of a Web Service do not need to know anything about the platform, object model, or programming language used to
implement the service; they only need to understand how to send and receive SOAP messages (HTTP and XML).
A Web Service Example
In the following example we will use ASP.NET to create a simple Web Service that adds two numbers
VB.
<%@ WebService Language="VB" Class="MyMath" %>
Public Class MyMath
Public Function
Return a + b
End Function
End Class
C#.
<%@ WebService Language="VB" Class="MyMath" %>
Public Class MyMath
{
[WebMethod]
Public int Add( Int a, Int b )
{
Return a + b;
}
}
Consuming (Calling) Web Service
Web Services can be consumed in 2 ways :
Select Project / Web site > right-click > Add Web Reference
Follow the wizard. If you select option “Web service in this solution”, it will do following things
Creates App_WebReferences folder
Create localhost having 2 files –
Then write following code in .aspx > Button click event :
[Here, WebService is the name of the web service.]
No comments:
Post a Comment