Ads

Monday, 1 December 2014

Make changes in wcf service without breaking existing clients - 4

Please refer previous posts of WCF service for better understanding.  Refer Here

From this above reference you must know to create WCF application.
Lets do changes in existing service:


Now Change the service contract name and change respective files as well as done below:



Accordingly to above change we need to change in class which implement this interface



And we also have to do changes in endpoint configuration in config file.
 
 

Now if we do only these thing to modify our WCF application. Then its working fine or new clients. But the existing client breaks and got an error while invoking our service.
Its because the proxy class that is created by the client previously is not the updated one.
So to prevent this we can use Name property of service contract attribute to give an explicit name for the service contract. 
By default the name property for service contract is set to the name of the interface.

This also can be identified in WSDL document exposed to client.

Here we can clearly seen the changes in WSDL document.
 
XML element “PortType” is nothing but the interface that the client uses to communicate with WCF services. So when it changed so the client invoke fails.

 Note: We can see the WSDL document by invoking the base URL of the wcf service in address bar of internet explorer.






No comments:

Post a Comment

Ads