views:

25

answers:

1

My clients could invoke the webservice dynamically by reflection. But how to get the cookies about the session with the webservice? I know set the webmethodattribute enablesession is true, but at the client the webservice object which was generated by reflection has not the attribute of cookiecontainer, how to make it to keep the session state?

A: 

Use the EnableSessionAttribute on your web service methods, this will make them using (and keeping) a session object, like explained here at MSDN.

Abel
I know that using the EnableSessionAttribute on the web service methods. My problem is how to keep the session at the client using reflection to dynamically invoke the webservice.thanks!
for example:using wsdl.exe to generate the referrence the webservice object at client.the code is like this:WebService ws = new localhost.WebService();ws.CookieContainer = cookieContainer;//keep sessionlblName.Text = ws.GetName();using reflection.the code is like this:object obj = activator.CreateInstance(t);System.Reflection.MethodInfo mi = t.GetMethod( methodname );return mi.Invoke(obj, args);//it can't keep the session with webservice.every invoking will create a new session.
@jollyray: Code pasted in the comment is hardly readable (not even if you'd use the obligatory \`code block here\` backticks), can you add it to your question for readabilities sake? Preferably a (partially) working example of your current code.
Abel