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)); }