|
The term "web service" refers to a form of a component that can be used remotely. Web services are invoked remotely using SOAP or HTTP-GET and HTTP-POST protocols. Web services are based on XML and return an "answer" to the client in XML format. Web services have all the advantages of components plus many more.
The most significant benefits include:
- Platform and Language Independence : Web services can be built and consumed on any operating system just as long as that operating system supports the SOAP protocol and XML.
- Automatic Upgrade : Unlike components, if a web service requires an update, that update is propagated to all applications consuming that web service immediately. This is because the actual methods and properties for the web service are invoked from the web server remotely, meaning that each function contained within a web service appears as a "black box" to a client: they aren't concerned with the way the function does its job, just as long as it returns the expected result.
Some Important Terms in Web Services:
- UDDI : UDDI (Universal Description, Discovery and Integration) is a registry that provides a place for a company to register its business and the services that it offers. People or businesses that need a service can use this registry to find a business that provides the service. When you search for a web service using UDDI's web service or web browser, UDDI returns a listing of web services that matched your criteria. This list is returned in the form of a DISCO or WSDL document.
- WSDL: WSDL (Web Services Description Language) is a language that describes a web service. It contains information such as where you can find the web service, methods and properties that it supports, its data types, and the protocol used to communicate with the web service. WSDL is based on the XML format and it's used to create proxy objects. Basically, without a WSDL document, developers wouldn't be able to use web services simply because they wouldn't know which methods and properties they support and also which communication method any particular web service supports.
- DISCO : DISCO (Abbreviated from disco very) is a list of WSDL documents. DISCO is used to group common web services together. DISCO documents are also in XML format.
- SOAP: SOAP (Simple Object Access Protocol) is a protocol to transport data to and from the web server. It is in XML format and allows you to transport a variety of data types used in .NET. As an alternative to SOAP, we can use HTTP-GET and HTTP-POST, which will be covered later in the article. These protocols return the output in a non-SOAP format; however this output is still in XML format.
Example: Demonstrate Web Service
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[ WebService (Namespace = "http://tempuri.org/" , Description = "New WEB Service Developed by V.D" )]
[ WebServiceBinding (ConformsTo = WsiProfiles .BasicProfile1_1)]
public class Service : System.Web.Services. WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[ WebMethod (Description= "GetEmployeeName: This will return the Employee Name." )]
public string getEmployeeName()
{
return "James Tube" ;
}
[ WebMethod (Description = "GetEmployeeAge: This will return the Employee Age." )]
public string getEmployeeAge()
{
return "23" ;
}
}
Output: Run this Web Service or F5

Note:
1]. There are 2 methods that are associated with this web service.
2]. The web service us under the default namespace that is http://tempuri.org. .
3]. Each XML Web service needs a unique namespace in order for client applications to distinguish it from other services on the Web.http://tempuri.org/ is available for XML Web services that are under development, but published XML Web services should use a more permanent namespace .
Output: If user clicks on the getEmployeeAge link

Click on the Invoke Button will display the value.
|