lundi 25 mai 2015

jax-ws soaphandler get response data value

I am pretty new with JAX-WS, I would like to get a value in the Response Data of my Soap Handler but I do not know how.

Below is the soap response in XML:

<soapenv:Envelope xmlns:soapenv="http://ift.tt/sVJIaE" xmlns:tsn="http://TestSession/BSCS_SessionManager" xmlns:ses="http://TestSession">
<soapenv:Header/>
<soapenv:Body>
    <tsn:LogonResponse>
        <ses:CS_ServiceHeader>
            <SourceSystem>NSK</SourceSystem>
            <TargetSystem>JOHN</TargetSystem>
            <ExternalID>20150525043213</ExternalID>
            <AgentName>APIJOHNGOL</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>

I would like to get the value of inside . I used the following but it seems to work only in stand alone application.

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

When I use the same code in my project... the result is always null.

Is there a way I can navigate from the response data and get value of ... the childnodes items indexes seems to be changing when run as standalone application and when run via tomcat.

I will be needing the signature value in the resquest data of my other operation (like logout, etc).

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire