I\'m using C# and connecting to a WebService via an auto-generated C# proxy object. The method I\'m calling can be long running, and sometimes times out. I get different err
I had got this error after changing the web service return type and SoapDocumentMethod.
Initially it was:
[WebMethod]
public int Foo()
{
return 0;
}
I decided to make it fire and forget type like this:
[SoapDocumentMethod(OneWay = true)]
[WebMethod]
public void Foo()
{
return;
}
In such cases, updating the web reference helped.
To update a web service reference:
If you are using .NET version 4.0. the validateRequestion is turned on by default for all the pages. in previous versions 1.1 and 2.0 it was only for aspx page. You can turn the default validation off. In that case you have to do the due diligence and make sure that the data is clean. Use HtmlEncode. Do the following to turn the validation off
In the web.config add the following lines for system.web
<httpRuntime requestValidationMode="2.0" />
and
<pages validateRequest="false" />
You can read more about this http://www.asp.net/learn/whitepapers/aspnet4/breaking-changes also http://msdn.microsoft.com/en-us/library/ff649310.aspx
Hope this helps.
That means that your consumer is expecting XML from the webservice but the webservice, as your error shows, returns HTML because it's failing due to a timeout.
So you need to talk to the remote webservice provider to let them know it's failing and take corrective action. Unless you are the provider of the webservice in which case you should catch the exceptions and return XML telling the consumer which error occurred (the 'remote provider' should probably do that as well).
I had this happen as a result of a configuration error in web.config. Checking the connection string etc might be the answer for the time out.
This is happening because there is an unhandled exception in your Web service, and the .NET runtime is spitting out its HTML yellow screen of death server error/exception dump page, instead of XML.
Since the consumer of your Web service was expecting a text/xml header and instead got text/html, it throws that error.
You should address the cause of your timeouts (perhaps a lengthy SQL query?).
Also, checkout this blog post on Jeff Atwood's blog that explains implementing a global unhandled exception handler and using SOAP exceptions.
Delete web.config file and insert again. http://forums.asp.net/post/916808.aspx