WCF的消息交換模式(MEP)有三種:請求/響應、單向模式和雙工模式。WCF的默認MEP是請求/響應模式。api
請求/響應模式操做簽名代碼以下,無需指定模式,默認就是。異步
[OperationContractAttribute] string Hello(string greeting,string mesg); [OperationContractAttribute] void SaveMesg(string mesg);
請求/響應模式內容:spa
參考網址:https://docs.microsoft.com/en-us/dotnet/framework/wcf/designing-service-contractscode
服務操做返回SOAP錯誤信息內容:對象
能夠在服務操做簽名指定返回的錯誤對象爲FaultException <TDetail>,該異常對象會轉換爲FaultContractAttribute指定的SOAP錯誤。blog
接口: [OperationContract] [FaultContractAttribute(typeof(GreetingFault))] string SampleMethod(string msg); 實現: public string SampleMethod(string msg) { throw new FaultException<GreetingFault>(new GreetingFault("A Greeting error occurred. You said: " + msg)); }