WCF的架构:using System.ServiceModel;
契约:Contract
[ServiceContract]
public partial interface IContract
{
[OperationContract]
string DocumentWebHostUrl();
}
服务:Service
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)]
public partial class ServiceBusiness : IContract
{
}
代理:Proxy
public partial class Proxy : ClientBase<IContract>, IContract, IDisposable
{
public Proxy()
: base()
{
}
public void EndSession(Guid sessionID)
{
base.Channel.EndSession(sessionID);
}
}
ASP.NET AJAX中的WebService }
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class SayHelloService : System.Web.Services.WebService
{
public SayHelloService() { }
[WebMethod]
public string SayHello()
{
Hello myHello = new Hello();
return myHello.SayHello();
}