2009-01-06 117 views

回答

4

WCF是专为各种渠道的,所以这是不是一个高水平的对象

你可以尽管像这样的东西

factory.Endpoint.Behaviors.Add(new WebHttpBehavior()); 
IMyContract proxy = factory.CreateChannel(); 
using (OperationContextScope scope = new OperationContextScope((IContextChannel)proxy)) { 
    proxy.MyMethod("Some data")); 
    var responseCode = WebOperationContext.Current.IncomingResponse.StatusCode; 
} 
((IClientChannel)proxy).Close(); 
factory.Close(); 
访问