scandihealth / lpr3-docs

https://scandihealth.github.io/lpr3-docs/
MIT License
11 stars 7 forks source link

Better error response when XML signature is invalid #50

Closed TueCN closed 6 years ago

TueCN commented 6 years ago

As seen in #49, we currently return a generic error response when signature is invalid

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
   <env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"/>
   <soap:Body>
      <soap:Fault>
         <soap:Code>
            <soap:Value>soap:Receiver</soap:Value>
         </soap:Code>
         <soap:Reason>
            <soap:Text xml:lang="en">Validation Failed.</soap:Text>
         </soap:Reason>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

This response should be updated to comply with DGWS, Soap, and WS-Security standards

TueCN commented 6 years ago

Now all SOAP faults should have a description of what went wrong.

Example response:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <env:Header xmlns:env="http://www.w3.org/2003/05/soap-envelope"/>
    <soap:Body>
        <soap:Fault>
            <soap:Code>
                <soap:Value>soap:Sender</soap:Value>
            </soap:Code>
            <soap:Reason>
                <soap:Text xml:lang="da-DK">ID kortet har en ugyldig type.</soap:Text>
            </soap:Reason>
            <soap:Detail>
                <medcom:FaultCode xmlns:medcom="http://www.medcom.dk/dgws/2006/04/dgws-1.0.xsd">invalid_idcard</medcom:FaultCode>
            </soap:Detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

Note: The locale of the reason text is set to the server's locale (which is da-DK at the moment). However, reason text might at times be in English (exceptions generated by libraries), therefore you cannot rely on the locale to determine what language the error text is written in.