Parse oasis xml documents

188 views Asked by At

I would like to find out the best way to parse responses using oasis xsd. I have the following response xml string but am not sure how to parse it, i tried copying the xsd from oasis but it fails to create jaxb objects. This is the xml response data:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-521833581">
    <wsu:Created>2017-09-07T00:00:02.002Z</wsu:Created>
</wsu:Timestamp>
</wsse:Security>
</soap:Header>
<soap:Body>
    <soap:Fault xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:c="urn:schemas-visa-com:transaction-data-1.0">
    <faultcode>wsse:FailedCheck</faultcode>
    <faultstring>
        Security Data : UsernameToken authentication failed.
    </faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
1

There are 1 answers

0
kwm On BEST ANSWER

Found a simple solution, not implemented this way ofcource, just an illustration:

SOAPBody body = soapResponse.getSOAPBody();
    if(body.hasFault()){
        LOG.debug("HAS LOG FAULT, LETS SEE WHAT ELSE...");
        LOG.debug("getFaultCode" + body.getFault().getFaultCode());
        LOG.debug("getFaultString" + body.getFault().getFaultString());
    }