c# - Calling web methods from the same web service -


i need write wrapper collection of web methods exposed in particular web service. makes sense stick new wrapper method in same service since it's affecting same type of object.

most of these web methods thin methods call static methods in other files, fine, have security logic done before these static method calls. rather recreate security logic before each method call want wrap, possible call these other web methods inside same service locally, or bad practice?

here's example:

[webmethod] public int smallmethod1(int a) {     //securitylogic     return anobject.staticmethod1(); }  [webmethod] public int smallmethod2(int b) {     //securitylogic     return anobject.staticmethod2(); }  [webmethod] public int wrappermethod(int c) {     return anobject.staticmethod1() + anobject.staticmethod2(); } 

in general want separate public interface of web service actual implementation cleanly possible, in example have done encapsulating them in anobject allows unit testing encapsulated methods separately (which big problem otherwise web methods).

having said testing perspective suggest rather doing this:

[webmethod] public int wrappermethod(int c) {     return anobject.wrappermethod(c) } 

this allow write tests test wrappermethod directly (encapsulated in anobject), rather trying recreate testing anobject.staticmethod1() + anobject.staticmethod2() in unit tests - gets messy because have same logic in 2 different spots.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -