简体   繁体   中英

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();
       }
   }

在此输入图像描述

In a similar situation, I would start with the following:

Test with the WCF Client and capture the trace file:

Test with the soapUI client and capture the Http Log

  • Clear the soapUI http log (one of the tabs along the bottom)
  • Send the message via the soapUI test request
  • Save the Http Log

Once you have the trace information for both clients, you should be able to compare the transactions and hopefully determine the source of the issue. In particular, I would suggest confirming the service addresses on both sides and then comparing the SOAP envelope to make sure the WCF bindings are set consistently with the soapUI settings.

In addition, you could also use Fiddler to view the web service communications. The following SO post provides good reference links. Fiddler and Monitoring Web Service Traffic

Hope this helps.
Regards,

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.

检查邮件配额设置,可能是您的服务发送的内容多于配置的内容

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM