svc中寫好接口方法
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)]
public 返回類型 方法名 (參數)
{
}
契約接口裏面要註冊這個方法
[ServiceContract]
public interface 接口名
{
[OperationContract, WfJsonFormatter]
public 返回類型 方法名 (參數)
}
頁面調用的時候需要先配置服務
頁面後臺調用接口
EndpointAddress endpoint = new EndpointAddress(System.Configuration.ConfigurationManager.AppSettings["Service"]);
using (var factory = new WfClientChannelFactory<契約接口>(endpoint))
{
service.要調用的接口方法
}