Unit-4 - ASP - Net and Web Development - Part-4
Unit-4 - ASP - Net and Web Development - Part-4
Processing
Internet
SOAP / HTTP
DataBase
Response
XML Web Service
• Main advantage of Web Service is Web Service messages are formatted as
XML, a standard way for communication between two incompatible
system. And this message is sent via HTTP, so that they can reach any
machine on the internet without being blocked by firewall.
• Advantages of Web service over COM and DCOM are :
1. COM provides platform services to a component while web service is
simply a program that communicates through message.
2. DCOM is based on the original Distributed Computing Environment
standard Remote Procedure Call while XML Web services are based
on open Web standard that are broadly supported.
3. Web services supports interoperability that means Cross platform
support.
4. Web services are loosely coupled means it can be extended.
Designing XML Web Service
• Surety of asynchronous communication done between a Web Application
that requests a Web Service and a Web server that provides the Web
Service.
• Try to create minimum methods.
• Follows oops concept to create Web Service.
• Minimize the time of response from Web Server to Web Application using
catch concept.
How web service work?
1. Discovery – Searches UDDI site for the specific Web Service.
2. Description – A detail of the selected Web service is returned to the client
application as a WSDL file.
3. Proxy creation – A local proxy to the remote service is created.
4. SOAP Message Creation – A SOAP / XML message is created and sent to
the URL specified in the WSDL file.
5. Listener – A SOAP listener at the host site receives the call and interprets
it for the Web service.
6. The Web Service – Performs its function, and returns the result back to
the client, via the listener and the proxy.
Protocols and Terms
1. XML
• It stands for Extensible Markup Language.
• XML is platform independent language.
• XML is a common standard for storing, carrying and exchanging data.
• Web service is called by web method and the argument – return values are
passed or returned as XML language.
2. SOAP
• SOAP stands for Simple Object Access Protocol.
• SOAP is a communication protocol.
• SOAP defines a uniform way of passing XML-encoded data.
• SOAP is remote procedure calls transported via HTTP.
• SOAP is a way by which method calls are translate into XML format and
sent via HTTP.
Protocols and Terms
3. WSDL
• WSDL stands for Web services Description Language.
• WSDL is an XML-based language used to define web service and to
describe how to access them.
• WSDL is an XML document.
• WSDL specifies the location, purpose, methods and format of the methods
of the Web service.
• It contains tags like <types>,<message>,<portType> and <binding> to
specify Web service.
• WSDL is an integral part of UDDI, an XML-based worldwide business
registry.
• WSDL is the language that UDDI uses.
Protocols and Terms
4. UDDI
• UDDI stands for Universal Description, Discovery and Integration.
• UDDI is a directory service where business can register and search foe
Web service.
• UDDI is a directory for storing information about web services.
• UDDI allows you to find web services by connecting to a directory.
• A description of the selected Web service is returned to the client
application as a WSDL file.
• UDDI is platform independent, open framework.
• UDDI can communicate via SOAP, CORBA, Java RMI Protocol.
• UDDI is built into the Microsoft .NET platform.
Web Service Example
• Step – 1 : Create new ASP.NET Website and add WebService.
Web Service Example
Web Service Example
Web Service Example
• Step – 2 : Default view of Web Service.
WebService :
using System.Xml.Linq;
<summary>
Summary Description for WebService
</summary>
[WebService(Namespace = “http://tempuri.org/”)]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
Web Service Example
public class WebService : System.Web.Services.WebService
{
public WebService()
{
}
[WebMethod]
{
public string HelloWorld()
{
return “Hello World”;
}
}
}
Web Service Example
• Step – 3 : Add Web Method
[WebMethod]
public int add(int a , int b)
{
return a + b ;
}
Web Service Example
[WebMethod]
public string CheckOddandEvenMethods(int a)
{
string results;
if (a % 2 == 0)
{
return results = a + "_" + "Is a Even Number";
}
else
{
return results = a + "_" + "Is a odd Number"; }
}
}
Web Service Example
• Step – 4 : Run it
Web Service Example
Web Service Example
• Step – 5 : Now create new ASP.NET Website to check and add web
Service Reference
Web Service Example
Web Service Example
Web Service Example
Web Service Example