I first built the web app, and a bunch of class libraries.
- The web app uses the class librares.
- The mobile app uses the expose public web service.
Now i'm thinking, since the mobile app has much of the same functionality of the web app, may开发者_运维技巧be I should make the web app also use the public web service?
Would it be a good idea for the web app and mobile app to use the same public api?
Please help me decide and let me know why it is a good idea or a bad idea!
thanks guys
EDIT: I guess if I have the web app use the public api, then performance may be degraded? since it has to go thr the network stack, and also need to provide authentication hmm ....
The disadvantage of using web service by a web application makes it slow, due to another request (althought even both are on a same server) and also cause performance issues. so it's not a good idea due to its disadvantages.
I have not tried the WCF with ASP.NET, but i guess it is better to use WCF with ASP.NET through TCP protocol. Even without TCP, it's faster than web service.
By keeping them separate you have the disadvantage of having to update two different assemblies if a change or upgrade of the shared code is required. If the performance hit of the extra request is too much for you then I would recommend trying to encapsulate the shared code in an assembly that both the Web Service and the Web App use. This will avoid the overhead of the additional request while removing redundant code.
If same class libraries are being used by the web service, I would not worry about consuming the web service from the application just for the sake of it.
Besides performance, another thing I would consider is the what type segregation I need for my application. I would make sure that all my business logic and security mechanism is at one place and preferably the code to put all the audit log as well.
By having a common Web Service (you can use other protocols to consume the service to improve performance), you can really leverage the features where you can add behaviours to make sure all the security and audit log is done in a uniform way and at one place.
精彩评论