This question is more of design issue rather than programming.
We are following SOA architecture with WCF Services, having multiple web services being consumed by multiple web applications. Lets say three web applications 1, 2 and 3 are consuming web service1, i.e. (ignore other web services for this question)
WebApp1 > consumes > WebService1
WebApp2 > consumes > WebService1
WebApp3 > consumes > WebService1
All three web applications are consuming same CreateUser()
function from WebService1
. Service will return success or error message depending on insert query in SQL Server database.
Here is the critical point, these success or error messages are being returned from database. Database table acts as central repository for messages to display in all applications. There are multiple applications with multiple messages. But lets focus on 3 applications with 2 messages. The table structure looks like this:
ApplicationID MessageID MessageText 1 5 User Saved Successfully. 2 6 User Inserted Successfully. 3 7 Record Saved Successfully. 1 8 User save failed. 2 9 User insert failed. 3 10 Record save failed.
Each application can have different MessageID
with different text, one for success and one for error. I want to return different messages based on given ApplicationID
. Each application is passing its own ApplicationID
in request to CreateUser()
.
How to write this function to return respective message text based on ApplicationID
.
Does it need to change table design or can be implemented in other better way?
Yes I think so.
Add the message logic in the web apps and not in the database. Then webService1 just returns if the user was created or not, and it is up the each app to display whatever they want. Then you don't need to patch you database if they want to change content or fix spelling errors.