views:

1809

answers:

1

I have inherited some code and I'm not very familiar in dealing with web services. Here is how the project is set up:

Under "Web References" there is a reference to the web service we are using. In that service's Reference.cs file there is class that inherits from SoapHttpClientProtocol, this class has a function called CandidateAdd() which calls this.Invoke (I'm thinking this makes the actual web method call)

Two classes then derive from the one in the Reference.cs file (one for the production environment and one for dev) and they only contain an override of GetWebRequest(Uri), here it sets

webRequest.KeepAlive = false;
webRequest.MaximumAutomaticRedirections = 30;
System.Net.ServicePointManager.MaxServicePointIdleTime = 18000;
webRequest.AllowAutoRedirect = true;
//webRequest.Timeout = 18000;

and returns the web request object.

The nature of the application is such that this web method will probably only be called 50 or so times a day, so it isn't like the server is getting very bogged down or anything, it seems more like something is setup incorrectly.

Thanks in advance for any help!

+1  A: 

Please post the complete exception you're seeing, including all InnerException. For instance:

try {
    using (CandidateService svc = new CandidateService()) {
        svc.CandidateAdd();
    }
}
catch (Exception ex) {
    string what_I_should_post = ex.ToString();
}

You may think it's obvious, but the stack trace may be a big clue.

You'll then want to figure out what the service is doing while this timeout is happening. It's probably executing a database operation to "add" the "candidate" - does the operation succeed on the server side? You may then want to try to find out what takes it so long.

The structure with the derived classes is something I haven't seen before, but it's a sound idea. That's probably not the problem. I wouldn't mess with that code during debugging, but if you have concerns about it, temnporarily copy the code from the one class into the other. That way, they'll both have the same WebRequest parameters.

John Saunders
Here is the error we are gettting (all the xxxx'ed out parts are our libraries)CandidateAdd Method FailureSystem.Net.WebException: The operation has timed out at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at xxxxx.yyyyyy.zzzzz.fffffffff.CandidateAdd(String InputFile) at xxxxx.yyyyyy.ServiceWrapper.CandidateAdd(String info, String wsServer)
spilliton
Also, it is succeeding on the server side, we are only getting these errors on our side.
spilliton
Ok, then I'd say the next step is to find out how long the server is taking to succeed; and why it's taking that long. Example: just yesterday, a changed query was timing out. A quick look with SQL Server 2008 Activity Monitor showed I was missing indexes. Simply accepting its suggestion speeded up the query 98%
John Saunders