Why does it work to add a parameter to my WCF service?

  • I select a new project -> WCF -> WCF Service Application
  • I am publishing a solution for my web server
  • I create a client application and add a link to my web server http://mywebserver/service1.svc
  • The client executes the GetData (1) method perfectly

Everything is fine - so far.

  • I am changing the service application from: Function GetData(ByVal value As Integer) to Function GetData(ByVal value As Integer, value2 As Integer)

  • I will post the solution again

  • To my surprise, the client application works fine with the GetData (1) method. I expect it to work and ask for the second parameter

Any idea why this is not a glitch?

I tried restarting the web server service - it still won't work.

I tried this code in Web.config ...

 <caching> <outputCache enableOutputCache="false"/> <outputCacheSettings> <outputCacheProfiles> </outputCacheProfiles> </outputCacheSettings> </caching> 

Still not working.

Any idea?

+4
source share
2 answers

This is simply because WCF uses Lax Versioning .

In many other scenarios, the service developer may make the assumption that adding a new, optional member to the data contract will not violate existing customers. This requires the service developer to investigate whether existing clients do not perform schema validation and that they ignore unknown data members. In these scenarios, it is possible to use the data transfer capabilities to add new members in the wrong way. The service developer can make this assumption by using the assurance that contract functions with version control data already exist for the first version of the service.

Many web service platforms, including WCF and XML web services, do not perform default schema validation and therefore allow additional elements that are not described in wsdl. This is not the case for every platform, and several java clients perform strict schema validation.

Try to remove the parameter now, you will not get the same results.

+4
source

http://msdn.microsoft.com/en-us/library/ff384251.aspx

Adding new parameters to the signature signature - The client is not affected. New settings are initialized to the default values ​​in the service.

+1
source

Source: https://habr.com/ru/post/1488487/


All Articles