none
How to check status code of web service call RRS feed

  • Question

  • Hi

    I am calling web service in my windows app. In our app whenever its web service call is success we get System.ServiceModel.CommunicationException

    exception saying "The content type text/plain of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 0 bytes of the response were: ''

    and sometimes no exception when its success.

    When i checked in Fiddler, i found that the http status code of service call is sometimes 503 other than success(202). This 503 exception also caught by CommunicaitonException.

    We have coded something like below to find whether call is success or not.
    private bool IsCallSuccess(Record[] recToSend)
    {

         try
                 {
                     using (ActivityServiceClient serviceClient = new ActivityServiceClient())
                     {
                         serviceClient.LogActivityRecordEntry(recToSend);
                     }
                 }
                 catch (System.ServiceModel.CommunicationException ex)
                 {                                
      return true;
                 }
                 catch (Exception ex)
                 {
                     return false;
                 }
     return true;
    }

    ActivityServiceClient is the service reference of wsdl file.

    In above code, if http status code is 503 then its caught by CommunicationException and its been considered as success instead of failure.

    Can anyone suggest me how to check status-code in this communication exception catch block.

    Thanks

    Kabila Krishnan


    Wednesday, August 27, 2014 2:18 PM

Answers

  • Hi Kabila Krishnan,

    Based on the provided details, The error was 503 ,service unavailable. 

    It means, your service hosted server IIS couldn't be ready to handle your request and provide you a solution for you. It may be server IIS stopped unfortunately when you make a call to the service. but in your, you are getting the response on certain frequent basis.

    so, can you share the details of hosting and configuration setting of the service?


    prabakaran.M

    Wednesday, August 27, 2014 5:49 PM
  • Hi Kabila,

    You can refer the below URL to find the error codes and with definitions. It may be useful to get an idea about your error code while connecting services.

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    Some times, imputing parameters also collapse the structure of soap request in the web service call.. so, check the input parameters also, if there is any xml content present in the xml then, use CDATA to mask that.


    prabakaran.M

    Wednesday, September 3, 2014 5:12 AM

All replies

  • Hi Kabila Krishnan,

    Based on the provided details, The error was 503 ,service unavailable. 

    It means, your service hosted server IIS couldn't be ready to handle your request and provide you a solution for you. It may be server IIS stopped unfortunately when you make a call to the service. but in your, you are getting the response on certain frequent basis.

    so, can you share the details of hosting and configuration setting of the service?


    prabakaran.M

    Wednesday, August 27, 2014 5:49 PM
  • Hi Prabakaran,

    Thank u very much for the reply.

    I want to check what kind of exception it is throwing and its http status code like 502/503 if any.

    Kindly share ur idea how to check this exception status code in the exception block.

    Thanks

    Kabila

    Monday, September 1, 2014 5:12 AM
  • Hi Kabila,

    You can refer the below URL to find the error codes and with definitions. It may be useful to get an idea about your error code while connecting services.

    http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

    Some times, imputing parameters also collapse the structure of soap request in the web service call.. so, check the input parameters also, if there is any xml content present in the xml then, use CDATA to mask that.


    prabakaran.M

    Wednesday, September 3, 2014 5:12 AM