jax-ws soaphandler获取响应数据值

时间:2015-05-25 09:25:38

标签: xml spring java-ee jax-ws soaphandler

我是JAX-WS的新手,我想在我的肥皂处理程序的响应数据中获取一个值,但我不知道如何。

以下是XML中的soap响应:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tsn="http://TestSession/BSCS_SessionManager" xmlns:ses="http://TestSession">
    <soapenv:Header/>
    <soapenv:Body>
        <tsn:LogonResponse>
            <ses:CS_ServiceHeader>
                <SourceSystem>SRCSYS</SourceSystem>
                <TargetSystem>TGTSYS</TargetSystem>
                <ExternalID>20150525043213</ExternalID>
                <AgentName>JOHNDOE</AgentName>
            </ses:CS_ServiceHeader>
            <ses:CS_LogonResponse>
                <CS_LogonResponseData>
                    <Signature>b9n9+BWWvJ0=|Qe9HGWuQXKt8zb6oaIoseiyIMsdy+svIYASZJLEy6bhmICr4LkNkOHrvLeDWAItQ7YU17N0eRDq0X36Ls8GSXR75SDsovL6DjAgSpN0AuC/BEkTJcQjVft1buhqfiyMrHsoqMU9c2vM=</Signature>
                </CS_LogonResponseData>
            </ses:CS_LogonResponse>
            <ses:Trailer>
                <Version>0.0.1</Version>
            </ses:Trailer>
        </tsn:LogonResponse>
    </soapenv:Body>
</soapenv:Envelope>

我想在<Signature>内获得<CS_LogonResponseData>的值。我使用了以下内容,但它似乎仅适用于独立应用程序。

代码:

SOAPMessage soapMsg = context.getMessage();
SOAPBody body = soapMsg.getSOAPBody();
body.getChildNodes().item(0).getChildNodes().item(3).getChildNodes().item(1).getChildNodes().item(1).getTextContent();

当我在项目中使用相同的代码时...结果始终为null。

我是否可以从响应数据导航并获取<Signature>的值...当作为独立应用程序运行时以及通过tomcat运行时,childnodes项目索引似乎正在发生变化。

我将需要我的其他操作的resquest数据中的签名值(如注销等)。

提前致谢

0 个答案:

没有答案
相关问题