This article sample source code or material download
Digression:. WebService technology has several years of history, about the theoretical knowledge of the foundation, omitted here, does not say. The Ajax technology that has been fired recently has also been abused very seriously, as far as details are concerned, I am not talking about the point.
The introduction of AJAX technology is relatively low, JavaScript and XML a little use, the individual thought that there is no content, can not fundamentally solve the enterprise's needs or problems, security, transmission of low-level and other aspects have fatal problems.
Why put WebService and Ajax together, for the simple reason that the similarities between the two are XML, and, more accurately, often--------XML according to the same data protocol.
This article neither explains the weakness of Ajax, nor does it webservice powerful, but illustrates how to use WebService technology and AJAX technology in an example.
I show how by example "User Login".
Create a virtual directory Userapp locally.
First create a WebService:
namespaceCjjer{
usingSystem;
usingSystem.Web.Services;
[WebService(Name="WebsCjjer",Description="一个验证用户登陆的web服务",Namespace="http://www.cjjer.com/webs/")]
publicclassUserService{
[WebMethod(Description="输入用户名和密,返回权限Int值,0表示失败",MessageName="Login")]
publicintLogin(stringUserName,stringUserPassword){
returnUser.Check(UserName,UserPassword);
}
};
}
We do not look at the details for the moment, note that this class has a header webservice, marking this is a Web service.
The CSC compiles, puts it into the bin directory, and then login.asmx the file:
<% @WebServiceClass = "Cjjer.userservice"%>
I will not say the details of the verification first, let's assume that User.check () returns the user level, and 0 indicates that the validation failed.