What are web services and why should we use web service ?
we service are a standardized way for developing interoperable applications i.e.
enabling an application to invoe a method of anoher application. These applications can be on the same Computer or different computer.
Web service use open standards and protocols like HTTP,XML and SOAP.
WebService Namespace is used to uniquely identify your web service on the internet from other services that are already there on the Web.
[WebService(Namespace = "http://stdpoint.com/webservices")]
[WebService]-->inherits from System.Web.Services.WebService
these tell that this contain code and Methord for WEB SERVICE
ASP.NET session or application state objectsinherit from System.Web.Services.WebService
using System.Web.Services;
[WebService(Namespace = "http://stdpoin.com/webservice/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
we service are a standardized way for developing interoperable applications i.e.
enabling an application to invoe a method of anoher application. These applications can be on the same Computer or different computer.
Web service use open standards and protocols like HTTP,XML and SOAP.
- Hyper Text Transfer Protocol (HTTP) is the protocl widely used by web services to send and receive messages.
- The messaging protocol is SOAP.(Simple Object Access Protocol) SOAP messages are in XML format.
Web Service : have .asmx extensionor(ASMX)
wes service used HTTP abd SMTP protocol
wes service used HTTP abd SMTP protocol
- HTTP widely used for web service to send and receive messages.
Messaging Protocol is SOAP
WebService Namespace is used to uniquely identify your web service on the internet from other services that are already there on the Web.
[WebService(Namespace = "http://stdpoint.com/webservices")]
[WebService]-->inherits from System.Web.Services.WebService
these tell that this contain code and Methord for WEB SERVICE
ASP.NET session or application state objectsinherit from System.Web.Services.WebService
using System.Web.Services;
[WebService(Namespace = "http://stdpoin.com/webservice/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
}
Consuming a web service in anther Project
Add a reference of web service project
Right click on References folder-->CalculatorWebApplication project and select Add Service Reference option
In the Address textbox of the Add Service Reference window, type the web service address and click GO button. In the namespace textbox type CalculatorService and click OK.
Right click on References folder-->CalculatorWebApplication project and select Add Service Reference option
In the Address textbox of the Add Service Reference window, type the web service address and click GO button. In the namespace textbox type CalculatorService and click OK.
No comments:
Post a Comment