0

As a quick run-through, i've got the following scenario

  • Website which hosts c# web api services
  • each webapi takes a 'request' message type and returns a 'response' message type

Also a winforms client app which has its own repository that consumes the webapi services for its own use. Is it good practice to put the request/response messages in a shared library which will be used by both the website, and by the client app bearing in mind if i update the webapi on the website, it could get out of sync with the distributed client apps, and may break functionality for them until they upgrade to the latest version.

thanks for any suggestions.

7
  • What is your question? I think the only thing that can be said now is that you shouldn't introduce breaking changes, or that you must update server and clients together. Commented Dec 8, 2014 at 11:01
  • @CodeCaster: a little patience will help understand the poster's question: "Is it good practice to put the request/response messages in a shared library which will be used by A, B, C, D...". Regarding the question, I think in the end you have to weigh what is more important: ensuring code reuse or predicting future changes. I do not have much experience in design, but I would stick with keeping the response object in a single location (dll). Commented Dec 8, 2014 at 11:06
  • what do you even mean by request/response messages. are you referring to an interface, like we have in WCF ? or just the class models that you are sending and receiving to/from the webApi ? Commented Dec 8, 2014 at 11:06
  • I am assuming he's talking about custom types its application called request/response... I am wrong, Milsnips? Commented Dec 8, 2014 at 11:07
  • 1
    @Veverke sure, but the versioning aspect is irrelevant to the shared type library. If you don't use shared classes, you still have to re-generate classes when introducing a breaking change. Commented Dec 8, 2014 at 11:08

1 Answer 1

2

If you cannot force your clients to update to the latest version, I would create a new endpoint with a corresponding shared library for each breaking change.

http://yourservice/api/v1/GetXY
http://yourservice/api/v2/GetXY
http://yourservice/api/v3/GetXY
....

And you could set up monitoring to see which old/obsolete endpoint is not in use anymore and turn it off if you want.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.