Best practices for error codes in web services

I have configured an exception for a specific error and I am getting something like this:

<ef_Anula_DocumentoResponse>
   <error>Null field</error>
</ef_Anula_DocumentoResponse>

      

Now I want to display the error code for each exception. What is the best way to achieve this? (These are just examples)

<error>1, Null field</error>
<error><1>Null field</1></error>
<error>1;Null field</error>

      

Is there a specific agreement for this type of situation?

My problem is when I do <error><1>Null field</1></error>

, '<1' and '1>' are replaced with <1 and 1> and it is considered bad practice to decode them to look SOAP UI friendly.

+3


source to share


2 answers


I realized from some of the links that the behavior is spected:

   <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
       <S:Body>
          <ns2:ef_Anula_DocumentoResponse xmlns:ns2="http://service.jaxws.sgd.ws.airc/">
             <error_code>100</error_code>
             <error>Null field</error>         
          </ns2:ef_Anula_DocumentoResponse>
       </S:Body>
    </S:Envelope>

      



Hope it helps in the future.

+1


source


You can try maybe the following xml output if you want to return multiple errors?



<errors>
    <error>
        <code>1</code>
        <desc>Null field</desc>
    </error>
    <error>
        <code>2</code>
        <desc>Null field</desc>
    </error>
</errors>

      

+1


source







All Articles