Search code examples
c#.netweb-serviceswcfwsdl

WCF web service call time out


I am consuming a web service from a url. When I test using SoapUI, I get the response immediately (See image below) and that the request data I sent out made it through to the other end.

So in my C# application I did the same thing, I consumed the web service wsdl and auto generated the proxy class. I create a request based on that proxy class with the exact same request data I used in SoapUI and sent out. I confirmed that at the other end they received my data successfully and no error is shown.

However, I never receive any ID back and after a while I would get this exception:

Error The HTTP request to 'http://someURLWebservice.com/WSoperation' has exceeded the allotted timeout of 00:00:59.9470000. The time allotted to this operation may have been a portion of a longer timeout.

Am I missing something here? I downloaded the WSDL and generated the mock service with SoapUI and if I make a call to that mock web service locally, I would get it right away.the ID back right away.

Here is my code:

 string serverURL = Settings.Default.ExtensionServiceURL;

 //Get Proxy class client
 ext.ExtWSPortTypeClient client = new ext.ExtWSPortTypeClient();
 EndpointAddress addr = new EndpointAddress(serverURL);

 try
   {
      client.Endpoint.Address = addr;
      Uri site = new Uri(serverURL);
      client.Endpoint.ListenUri = site;
      ExtensionData eData = new ExtensionData();
      client.ChannelFactory.CreateChannel();

      Console.WriteLine("Sending Locator Event Request to Web Service");
      ext.locatorEventResponse1 resp = await client.locatorEventAsync(eData.GenerateLocatorEventRequest(ev));
   }
   catch (Exception ex)
   {
       Console.WriteLine("Error " + ex.Message);
   }
   finally
   {
       if (client != null)
       {
          ((ICommunicationObject)client).Close();
       }
   }

enter image description here


Solution

  • So I ended up configure Fiddler2 to sniff my SoapUI request and compare it against my application request. In the the Application request header I saw the following:

    Content-Type: text/xml; charset=utf-8
    SOAPAction: ""
    Host: engage.ext-inc.com
    Content-Length: 1036
    **Expect: 100-continue**
    

    That Expect:100-continue is not in the SoapUI request which successfully sent out and got the response. With this in mind I took the SoapUI request in Fiddler and compose a new one base on it...except I put in Expect:100-continue and guess what, I received no response.

    Upon reading about it I came across this link

    And voila, upon putting ServicePointManager.Expect100Continue = false; into my code prior making the web service call I get the response back right away.