2009-01-06 118 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(); 
訪問