开发者

Using web service internally in web service

开发者 https://www.devze.com 2023-04-06 04:11 出处:网络
What do people generally do when a web service has a bunch of methods and one method wants to 开发者_JS百科use one of the other methods? Calling the method as any other external caller would do seems

What do people generally do when a web service has a bunch of methods and one method wants to 开发者_JS百科use one of the other methods? Calling the method as any other external caller would do seems like a waste of resources.

Eg:

[Web Method]
public BlahObject GetBlah() {
}

[Web Method]
public String Blah2() {
    var blah = GetBlah(); // this will involve serializing, deserializing, etc.
}


It depends on where your service resides and the level of decoupling you are expecting.

Also if both the services are in the same hosting environment and if you need to call methods of one service from another frequently - then of course you need to rethink about the granularity of your service design.

Directly calling a service from other service would provide you a highly decoupled solution - but with a performance impact. If all the services under your control - best thing is to design the service interface more carefully to avoid such calls...


I am not familiar with C# but you should be able to call the method directly without going through the web service api.

Even you can re factor your code to have web method separately and function method separately. Then you can call the function methods directly from any method.

0

精彩评论

暂无评论...
验证码 换一张
取 消