简体   繁体   中英

Getting a particular field in soap body in org.apache.cxf.binding.soap.SoapMessage

Is there any way to get a particular field value in a SoapMessage which is built from an XML file.

Here is my incoming soap message,

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.example.com</wsa:Action>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">8d6f49b9-22c6-41d9-a1fb-bc07c82pbhar</wsa:MessageID>
<wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
<Address xmlns="http://www.w3.org/2005/08/addressing">http://bcd.com</Address>
</wsa:From>
<wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
<Address xmlns="http://www.w3.org/2005/08/addressing">http://blah.com</Address>
</wsa:ReplyTo>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">https://blah2.com</wsa:To>
</soap:Header>
<soap:Body wsu:Id="id-8" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<ns2:abc xmlns:ns2="abc" xmlns:ns3="abc" xmlns:ns4="abc">
<ns2:FunctionCallIdentifier>https://bcd.com</ns2:FunctionCallIdentifier>
<ns2:ValidityPeriod>120000</ns2:ValidityPeriod>
<ns2:fieldOne>
<ns2:Subfield xsi:type="ns2:MSId_AliasType" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:property1>IWantToGetThis</ns2:property1>
</ns2:Subfield>
</ns2:abc>
</soap:Body>
</soap:Envelope>

Now, I want to get the "property1" file, how do I do that, all I can see is getHeaders(), getContextualProperty(),etc, etc

Thanks!

Maybe this link can help you:

How to parse SOAP message into Jaxb classes

Jaxb is framework for processing XML documents, as sopa body is a XML, you can process it with Jaxb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM