开发者

how to get which webservice is calling a method

I have a webservice 'mywebservice' and a web method 'mywebmethod' defined in it. This web method calls a function 'callme()' which is defined in another class. I want to get the service name which is calling this function and also the methodname. I want this in 'callme()' function.

--'mywebservice.asmx.cs'

[WebMethod]
public void mywebmethod
{
     callme();
}

-- 'class1.cs'

public void callme()
{
     // --- I want service name(mywebservice) & methodname(mywebmethod) here.开发者_JS百科
}


One possible way could be to use StackTrace class (see example section to get started) to walk back to call stack to get type name & method name - this will give you the names for class/method implementing the service.

Mind you that stack trace construction is an expensive operation - as such, I would recommend to pass necessary information as parameters to the method. Further, if you could state why you need this information (service & method name), you may get an better answer to solve your actual problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜