Sunday, September 12, 2010

WCF Service this.Invoke The operation has timed out

Well I had another issue which stumped me for awhile. It's a simple fix, but I spent a while on it so I figured I would try and save others similar pain.

So here is the scenario. I just added a new Web Service for my project to consume using the URL which pointed to the source WCF Service. I have consumed a lot of web services in the past so it was nothing new and I built out all the code rather quickly for it. However, when I tried to run it, it would always timeout, no other errors just a timeout:


Server Error in '/' Application.

The operation has timed out

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.WebException: The operation has timed out

Source Error:


Line 82:         [return: System.Xml.Serialization.XmlElementAttribute(IsNullable=true)] 
Line 83:         public string SaveMethod(string AppId, [System.Xml.Serialization
.XmlElementAttribute(IsNullable=true)] CustomObject myobject) {
Line 84:             object[] results = this.Invoke("SaveMethod", new object[] { 
Line 85:                         AppId, 
Line 86:                         myobject});

Source File: C:\path\Reference.cs Line: 84

Stack Trace:


[WebException: The operation has timed out]    
System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request) +358    
System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request) +42    
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, 
Object[] parameters) +268    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, 
Object o, Object t, EventArgs e) +37    System.Web.Util.CalliEventHandlerDelegateProxy
.Callback(Object sender, EventArgs e) +91    System.Web.UI.Control.OnLoad(EventArgs e) +148    
System.Web.UI.Control.LoadRecursive() +122    System.Web.UI.Page.ProcessRequestMain(Boolean 
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3412 


Version Information: Microsoft .NET Framework Version:2.0.50727.3615; ASP.NET Version:2.0.50727.3614


I removed some of the stack trace that was specific to my application...

After fighting with this issue for a day or two, stepping through the code, monitoring calls at both ends, the basic troubleshooting stuff. I finally read this blog post again, who knows what neurons in my brain got triggered and why, but it clicked... I had added my WCF Service as a Web Service. Adding WCF Services isn't quite as intuitive as the old web service was because there is no Add WCF Service option in the visual studio 2008 gui that I could find. Instead you have to right click on the project name itself and click Add Service Reference.

---------------------

The next error I fought trying to get this web service up was:
System.Net.WebException: The remote server returned an error: (405) Method Not Allowed.
This was resolved by making sure that the "endpoint address" on the server had the service URL without the final file name. While the client "endpoint address" had the fully qualified url of the wcf service.

5 comments:

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. Rešid Fućka Jebo ŠumuJanuary 13, 2012

    maaaaaaaaaaaaaaaaaaaaaaaaaaan. I went through gazillion sites and no one mentioned this... Thanks for this, I was working on this for 5 hours. love you <3

    ReplyDelete
  3. That was a very good post, like other i too searched in lots of website for a resolution and finally tried this. I'm impressed with your Math profile as well.

    ReplyDelete
  4. AnonymousMay 10, 2012

    awesome... thanks!

    ReplyDelete
  5. Thanks saved my time

    ReplyDelete

Please leave your thoughts, I love hearing what you got out of the post. Spam comments will be removed.