Firstly, this is no documentation for Web Services and neither do i wish to make any. I dont discuss any inernals on how web services work. It is just a step-by-step guide to develop Web Services and consuming them in .NET. I prefer VB.NET for this tutorial. I use layman terms and if you have some problem with my language, visit MSDN and learn-dont bother to visit again.
What are Web Services??
I would say a Web Service is a DLL that is referenced through the internet using HTTP protocol. Instead of shipping your business logic along with the application, as a DLL, we can make it a web service and host it as a website. But all it does is to provide the same services as a DLL - i.e no presentation involved.
How to create a web Service?
1. Start Visual Studio 2003. Go to VB Projects -> ASP.NET Web Service -> Give a project name and click OK.
2. Click on Switch to code view on the designer view you get. We dont need a designer so we go to the code view.
3. You can notice a Hello World method commented. Copy the same and paste it and this time uncomment it. That is your code file should look like this.
_
Public Class Service1
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
' _
'Public Function HelloWorld() As String
' Return "Hello World"
'End Function
<WebMethod()>
Public Function HelloWorld() As String
Return "hello world"
End Function
End class
4. Ok your web service is ready. Just "Build" the project clicking on CTRL + f5). It starts up IE showing a sample page. That looks like the one shown below!
What are Web Services??
I would say a Web Service is a DLL that is referenced through the internet using HTTP protocol. Instead of shipping your business logic along with the application, as a DLL, we can make it a web service and host it as a website. But all it does is to provide the same services as a DLL - i.e no presentation involved.
How to create a web Service?
1. Start Visual Studio 2003. Go to VB Projects -> ASP.NET Web Service -> Give a project name and click OK.
2. Click on Switch to code view on the designer view you get. We dont need a designer so we go to the code view.
3. You can notice a Hello World method commented. Copy the same and paste it and this time uncomment it. That is your code file should look like this.
Public Class Service1
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
' WEB SERVICE EXAMPLE
' The HelloWorld() example service returns the string Hello World.
' To build, uncomment the following lines then save and build the project.
' To test this web service, ensure that the .asmx file is the start page
' and press F5.
'
'
'Public Function HelloWorld() As String
' Return "Hello World"
'End Function
<WebMethod()>
Public Function HelloWorld() As String
Return "hello world"
End Function
End class
Service1
The following operations are supported. For a formal definition, please review the Service Description.
HelloWorld
5. Click on the "HelloWorld" and you are taken to a page that has the SOAP Headers and HTTP Post descriptions along with a Invoke button. Click on the "Invoke" button. the output you get is as follows.<xml version="1.0" encoding="utf-8" ?>
<string> xmlns
<string> xmlns