R
Ram P. Dash
Hi:
I had the following client proxy code autogenerated:
Code I:
[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://tempuri.org/ProcessCondensateFile", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/")]
public bool ProcessCondensateFile(CondensateFileContainer condensateFileContainer) {
object[] results = this.Invoke("ProcessCondensateFile", new object[] {
condensateFileContainer});
return ((bool)(results[0]));
}
While debugging, I would loose control at this.Invoke(). i.e. The app never reached the return statement nor did it time-out (the default is 100). Not sure of what is happening, I overrode GetWebRequest() method of the client proxy to do the following:
Code II:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = null;
try
{
webRequest = (HttpWebRequest) DoWorkHandler(uri);
}
catch (Exception e)
{
string msg = e.Message;
}
return webRequest;
}
private WebRequest DoWorkHandler(Uri uri)
{
return base.GetWebRequest(uri);
}
Sure enough, I lost control in DoWorkHandler at the return statement. Armed with this information, I tried to call the DoWorkHandler asynchronously like below with my own timeout since the timeout of the webservice client proxy never worked at the first place:
Code III:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = null;
try
{
WorkDelegate d = new WorkDelegate(DoWorkHandler);
IAsyncResult res = d.BeginInvoke(uri,null,null);
if(res.IsCompleted == false)
{
res.AsyncWaitHandle.WaitOne(10000,false);
if(res.IsCompleted == false)
throw new ApplicationException("Timeout");
}
webRequest = (HttpWebRequest) d.EndInvoke((AsyncResult)res);
}
catch (Exception e)
{
string msg = e.Message;
}
return webRequest;
}
Surprisingly this works. i.e. The request is passed to the service and I am getting a response back (no timeouts either). I would rather like to have Code I as opposed to Code III. Can somebody enlighten me as to why is this happening? I am working on a Windows XP workstation with Visual Studio 2003. My client and service are on the same box. I've at least 20 other services / clients running under same box using the same kind of interface without any hiccup.
Thanks,
Ram
I had the following client proxy code autogenerated:
Code I:
[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://tempuri.org/ProcessCondensateFile", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/")]
public bool ProcessCondensateFile(CondensateFileContainer condensateFileContainer) {
object[] results = this.Invoke("ProcessCondensateFile", new object[] {
condensateFileContainer});
return ((bool)(results[0]));
}
While debugging, I would loose control at this.Invoke(). i.e. The app never reached the return statement nor did it time-out (the default is 100). Not sure of what is happening, I overrode GetWebRequest() method of the client proxy to do the following:
Code II:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = null;
try
{
webRequest = (HttpWebRequest) DoWorkHandler(uri);
}
catch (Exception e)
{
string msg = e.Message;
}
return webRequest;
}
private WebRequest DoWorkHandler(Uri uri)
{
return base.GetWebRequest(uri);
}
Sure enough, I lost control in DoWorkHandler at the return statement. Armed with this information, I tried to call the DoWorkHandler asynchronously like below with my own timeout since the timeout of the webservice client proxy never worked at the first place:
Code III:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = null;
try
{
WorkDelegate d = new WorkDelegate(DoWorkHandler);
IAsyncResult res = d.BeginInvoke(uri,null,null);
if(res.IsCompleted == false)
{
res.AsyncWaitHandle.WaitOne(10000,false);
if(res.IsCompleted == false)
throw new ApplicationException("Timeout");
}
webRequest = (HttpWebRequest) d.EndInvoke((AsyncResult)res);
}
catch (Exception e)
{
string msg = e.Message;
}
return webRequest;
}
Surprisingly this works. i.e. The request is passed to the service and I am getting a response back (no timeouts either). I would rather like to have Code I as opposed to Code III. Can somebody enlighten me as to why is this happening? I am working on a Windows XP workstation with Visual Studio 2003. My client and service are on the same box. I've at least 20 other services / clients running under same box using the same kind of interface without any hiccup.
Thanks,
Ram