In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to create a WCF agent", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to create a WCF agent" this article.
The WCF agent is still quite commonly used, so I studied the WCF agent and shared it with you here. I hope it will be useful to you. The proxy class generated by SvcUtil is derived from the class ClientBase and is defined as:
Public class ClientBase: IDisposable {protected ClientBase (string endpointConfigurationName); protected ClientBase (Binding binding,EndpointAddress remoteAddress); public void Dispose (); protected T InnerProxy {get;} / / other members}
This InnerProxy attribute is the type of contract that the client needs to consume, and a subclass of ClientBase generated by SvcUtil simply WCF it to the method call. The client needs to instantiate a proxy object and provide it with constructor endpoint information-either the endpoint section name from the configuration file or the endpoint address and binding object when not using a configuration file. The client can then use the proxy method to invoke the service, and when the client is finished, it needs to close the proxy instance:
MyContractProxy proxy = new MyContractProxy ("MyEndpoint"); proxy.MyMethod (); proxy.Close ()
Shutting down the WCF agent terminates the session with the service and closes the connection. Alternatively, you can use the agent's Dispose () method to turn it off. The advantage of the Dispose () method is that you can use the using statement to call it, even when faced with exception handling:
Using (MyContractProxy proxy = new MyContractProxy ("MyEndpoint")) {proxy.MyMethod ();}
One endpoint for each contract type in the client profile can be assigned as a default endpoint. The default endpoint is an endpoint section with no name flag or only an empty name (""):
A default endpoint is only ideal; when creating a proxy for the default endpoint, you can use the default constructor of the WCF proxy to make it use the default endpoint:
MyContractProxy proxy = new MyContractProxy (); proxy.MyMethod (); proxy.Close (); that's all of the article "how to create and use WCF agents". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.