java - 解析oasis xml文档

标签 java xml xsd oasis

我想找出使用​​ oasis xsd 解析响应的最佳方法。我有以下响应 xml 字符串,但不确定如何解析它,我尝试从 oasis 复制 xsd,但无法创建 jaxb 对象。这是 xml 响应数据:

<?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>

最佳答案

找到了一个简单的解决方案,不是以这种方式实现的,只是一个说明:

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());
    }

关于java - 解析oasis xml文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46099424/

相关文章:

java - 如何从 xml 字符串内容构建 HierarchicalConfiguration 对象?

XML 自定义序列化

java - Jetty 列出端口 80 上的应用程序,该应用程序通常位于另一个端口上

java - Mockito 测试 RestClient aSync

java - 如何在 Android 项目中创建新包

python - 将 PMML 3.2 模型导入到 Python 中进行调试并转换为 4.2

java - 如何使用jstack获取堆栈跟踪历史记录?

xna - 将字符串与 c#/XNA 中的对象进行比较

c++ - 使用 Xerces 验证未定义架构的 XML

java - Xsd 验证错误