Webservice SOAP Error handling

DanikRaikhlin.4786DanikRaikhlin.4786 NLMember ✭✭
edited October 2012 in Xamarin.Android

Hi,

I'm trying to call a soap webservice and i created my webservice to return a SoapException in case user enters invalid data. The service works if user enter correct data. However when invalid data is entered i am expecting to get a SoapException (Or FaultException) but i'm getting InvalidOpperationException with message:

Not supported Content-Type in the response: 'text/html; charset=ISO-8859-1'

Response error message:


  GW fout 500
Interne server fout


I know that 500 error is internal server error so i might havent setup web.config propperly or its something else.

So my question is, how to properly catch errors that are thrown by the webservice?

Thanks in advance!

Posts

  • JoeJoe AUMember

    Best to post your calling code. It's all guesswork otherwise.

  • try
    {
    SoapAccount response = service.Register("AKSDKerD1KFKDSqweKK123ASKDKasdWQwKEKDAS1s23ASDK","[email protected]","danik");

            }
            catch ( SoapException  ec)
            {
                tvRegisterOutput.Text = "SoapException " + ec.Message;
            }
            catch ( FaultException ec)
            {
                tvRegisterOutput.Text =  "FaultException " + ec.Message;
            }
            catch ( Exception  ec)
            {
                tvRegisterOutput.Text = "Exception " + ec.Message + ec.StackTrace;
            }
    

    The first parameter of Register is Apikey which is incorrect so the service is throwing SoapException however all im catchin is Exception.
    The

  • DanikRaikhlin.4786DanikRaikhlin.4786 NLMember ✭✭
    edited October 2012

    soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    soap:Body>
    soap:Fault>
    faultcode>soap:Client
    faultstring>System.Web.Services.Protocols.SoapException: Api key is not correct
    at Intest.WSMobile.Register(String key, String email, String password)/faultstring>
    detail/>
    /soap:Fault>
    /soap:Body>
    /soap:Envelope>

    (Note i removed all "<" so it will show the text here)

    This is what the response is so i am expecting SoapException but i get a InvalidOperationException.

    Does anyone know the solution?

  • Found the solution. It was server side fault. I was just raising SoapException however that is not sufficient. This site explains how to do it. Now the SoapException is being raised.

Sign In or Register to comment.