开发者

How do you configure a WCF client in production?

There are numerous resources available on WCF and configuration (both programmatic and via app.config). However, I have not seen a good resource on practical management of this configuration, particularly in a production environment.

WCF is powerful in that the framework allows configuration via the app.config file so that you can tweak various settings without having to recompile code.

When installing a WCF client, how do you easily configure the client to point to the right server? This is probably the most common thing I can think of to configure after installing. For some context, suppose I ship a product which has a server component and a client component. Customers can install both wherever. While an xml file is powerful for post-development configuration, it is not user-friendly at all. Given that there can be s开发者_JAVA技巧everal dozen endpoints in a config file, does the admin or end user have to manually change all of them? I know I could do everything programmatically, but then I essentially am re-implementing all of the out-of-the-box plumbing.

Above question, more generalized is: how can I simplify WCF configuration via some basic UI without re-implementing what is provided by the framework?


If you want user friendly installation you will use some installer where you simply set some configuration values. Check either installer project provided as part of Visual studio or more powerful (and much more complex) WiX. If you don't have installer you already chose that users are supposed to configure everything manually.

If your only problem is address of services and you plan to deploy services and clients to single LAN you can also add WS-Discovery (available in WCF 4) where clients are able to find service on the network.


if you like to have/make a nice UI to edit those settings, the user input from that UI will need to be saved somewhere and you will have to use it when creating your service calls on the clients or setting up your hosted services on the server. Personally I would store in the database and will use them to configure the WCF endpoints at runtine with coded approach.

this has also some advantages, all backed up with db backup, remote connection and inspection, no risk to overwrite files on updates and so on.

If your setup/application has no database then configuration files are also ok and probably the only way, I would not save anything in the Registry anyway.


You could use the settings framework to store the endpoint address. You can easily read and save settings and they'll be stored in the %APPDATA% location so you don't need to worry about permissions. You'd need just a small configuration UI where the user can enter the server name. Validate that configuration by adding a simple Hello service to your server and try to reach that service in that UI. So you can give the user immediate feedback if the server address is right.

The other option is to implement a discovery protocol. A related question is here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜