Quantcast
Channel: WCF, ASMX and other Web Services
Viewing all articles
Browse latest Browse all 555

Calling webservice (WCF) with Invoke method from MethodInfo class

$
0
0

Hi.

I have a web application without reference to webservice. My application needs connect with any web services. To make this, the application get a list of web services when it need.

To call this web services, we create an instance of MethodInfo class and use the Invoke method like this:

methodInfo.Invoke(instance, BindingFlags.InvokeMethod, null, null, null);

This work fine. The next step would be stop service at any moment. Either a timeuot or a simple button.

var thread = new Thread(() =>
{  
 methodInfo.Invoke(instance, BindingFlags.InvokeMethod, null, null, null);                        
});

thread.Start();

if (!thread.Join(TimeSpan.FromSeconds(60)))
{
  thread.Abort();
  throw new Exception("Timeout - 1 minute");
}

The code above is work fine. The instance parameter contains the name of the web service that I need to connect. However if I verify in database, the process is still running.

Can anyone help me, please?

Thanks

Thiago


Viewing all articles
Browse latest Browse all 555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>