问题
We have a webservice that is used by a lot of other processes. It takes an object (made from an XSD) as an argument. One of the properties (a datetime) in this object is now made nullable.
The question is: Do I now have to find all of the processes that reference this webservice and update their reference, in order for them to keep working?
Thanks.
回答1:
This is a tricky question.
I am thinking you should be fine because you are not removing or add new parameters to the interface.
It is just a simple change to an existing parameter and in my opinion you are just relaxing the constraint here. Instead of enforcing the parameter to not able to accept null, you are saying it now is.
I believe existing processes must have already be setting non-nullable value for that dateTime property? So for new processes to take advantage of the change, they will have to update the reference, otherwise no change is required.
Still, changing service contract is generally a bad idea though. Have you look at including the change in your release notes? So that your clients are aware and can do the appropriate measures.
Here is another list of breaking changes that might give you trouble.
- Remove operations
- Change operation name
- Remove operation parameters
- Add operation parameters
- Change an operation parameter name or data type
- Change an operation's return value type
- Change the serialized XML format for a parameter type (data contract) or operation (message contract) by explicitly using .NET attributes or custom serialization code
- Modify service operation encoding formats (RPC Encoding vs. Document Literal)
回答2:
Changing a service contract, if only making a property nullable from non-nullable requires the service references to be updated.
Rather than each project to uses the service to create its own references, you could create a shared project where you maintain a service reference. That way, you do not need to go through all your projects and applications and go through this process for each and every one of them.
A better solution still is to have your POCOs defined in a separate project/assembly, and reference that at both the service and the client. WCF and VS are smart enough the identify that it does not have to create proxy classes for the service classes, and instead will use the POCOs from the separate assembly. You even wouldn't have to update the service reference if you change a property in a class that is exposed by the service, only when you add/remove classes or change the service interface.
来源:https://stackoverflow.com/questions/37718399/do-i-need-to-update-wcf-service-references-when-making-an-agument-optional