Can I specify a contract's Name and Namespace in app.config?
I'm pretty new to WCF and SOA, so I apologize if the question is poor.
The way I see it, if I could specify a contract's Name and Namespace in app.config, I could change the service that my client contracts use at runtime rather than compile time. Without the ability to specify Name and Namespace in app.config, my client contracts are limited to connecting to services with contracts with the same name and in the same namespace开发者_JAVA百科. Is this right?
So is there a way to choose Name and Namespace for a given contract in app.config? If not, why not?
What you ask for doesn't make sense. The name and namespace identify the contract. The contract cannot change without changing the client. This is why service versioning is often performed by adding a new contract (with a new name/namespace combination), not by changing an existing contract.
You should think of a contract as being an unbreakable agreement between the client and service - you will always provide that set of operations.
You can, on the other hand, change the endpoint that your client references if you decide you'd like your client to use a different implementation of the contract. You can also change the binding by which the implementation is reached. But you must always maintain the same contract, unless you'd like to begin lying to your clients.
精彩评论