Thursday, April 21, 2011

Channel Factory in WCF

Hi all i am new to WCF i wanted to know if i use channel factory and if i make any changes in service contract whether the changes will be updated automatically in the client system or not???If the changes are updated automatically how????

From stackoverflow
  • No, the channel factory is not updated automatically - you have to update your service reference (if you added it using Visual Studio's Add Service Reference) or you need to re-create the client side proxy from the WSDL/XSD or service URL.

    UPDATE: of course, if you're sharing the service and data contracts in an assembly between both the service and the client, then of course you have the client up to date as soon as you have the new service contract DLL in place...

    If you want to enable this sharing of service and data contracts, use the following setup:

    • in your Contracts assembly, have all the service contracts (interfaces) and data contracts (data types)

    • in your implementation of the service, reference that Contracts assembly and implement the service contract(s)

    • in your client-side proxy, also reference that shared Contracts assembly, and use ChannelFactory<T> to create a channel factory for the service contract interface T.

    With this setup, whenever you make a change to the shared contract assembly, both service implementation and client side proxy will "get" those changes, e.g. they're always up to date and using the same service and data contracts

    : Thnaks..If i add service DLL in client side then if i make any changes in the service then what should be done in order to update the client side????
    marc_s : If you share the DLL with the service and data contracts, then you don't have to do anything - you're sharing the same code base, after all, so any changes in your service contracts are in the client side proxy automatically (you didn't mention this very important fact in your question....)
    : sorry marc its my mistake...can u give me an example how to use the channel factory and make changes in the service without changing anything in the client side????
    : Thanks marc...it really helped me

0 comments:

Post a Comment