How can the error 'Client found response content type of 'text/html'.. be interpreted

后端 未结 9 1508
深忆病人
深忆病人 2020-12-18 17:54

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

相关标签:
9条回答
  • 2020-12-18 18:35

    The webserver is returning an http 500 error code. These errors generally happen when an exception in thrown on the webserver and there's no logic to catch it so it spits out an http 500 error. You can usually resolve the problem by placing try-catch blocks in your code.

    0 讨论(0)
  • 2020-12-18 18:36

    The problem I had was related to SOAP version. The asmx service was configured to accept both versions, 1.1 and 1.2, so, I think that when you are consuming the service, the client or the server doesn't know what version resolve.

    To fix that, is necessary add:

    using (wsWebService yourService = new wsWebService())
    {
        yourService.Url = "https://myUrlService.com/wsWebService.asmx?op=someOption";
        yourService.UseDefaultCredentials = true; // this line depends on your authentication type
        yourService.SoapVersion = SoapProtocolVersion.Soap11; // asign the version of SOAP
        var result = yourService.SomeMethod("Parameter");
    }
    

    Where wsWebService is the name of the class generated as a reference.

    0 讨论(0)
  • 2020-12-18 18:40

    Is your webservice configured correctly in IIS? The pool its using, the version of ASP.NET (2.0) is set? Can you browse the .asmx?

    Talking about exceptions, try to put an try-catch block in the line that access your webservice. Put and catch(System.Web.Services.Protocolos.SoapException).

    Also, you can set a Timeout for your webservice object.

    0 讨论(0)
提交回复
热议问题