In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to define WCF callback contract". In daily operation, I believe many people have doubts about how to define WCF callback contract. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how to define WCF callback contract". Next, please follow the editor to study!
A service contract can contain at most one callback contract. Through the ServiceContract feature, you can specify a callback contract:
Interface ISomeCallbackContract {[OperationContract] void OnCallback ();} [ServiceContract (CallbackContract = typeof (ISomeCallbackContract))] interface IMyContract {[OperationContract] intDoSomething ();}
The WCF callback contract does not need to mark the ServiceContract feature, but the OperationContract feature must be marked for the operation of the service in the callback contract. In the metadata that imports the callback contract, the callback contract ends with Callback. For simplicity, we define the callback contract with the suffix Callback. To host a callback object, the client needs to instantiate the callback object and then create a context object through it. Note that if the WCF callback contract is used, the proxy class generated by the client must inherit from DuplexClientBase
Proxy class, which is a special proxy class that supports two-way communication. Note that the constructor parameters of this class can receive either a context object of type InstanceContext or a callback contract object of type object. Class MyCallback: IMyContractCallback {public void OnCallback () {...}} IMyContractCallback callback = new MyCallback (); InstanceContext context = new InstanceContext (callback)
Assuming that the client's proxy class is MyContractClient, the proxy object can be obtained on the client through the context object:
MyContractClient proxy = new MyContractClient (context); at this point, the study on "how to define the WCF callback contract" is over, hoping to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.