在org.apache.cxf.binding.soap.SoapMessage中获取soap body中的特定字段

时间:2014-12-29 14:44:57

标签: java web-services soap cxf

有没有办法在从XML文件构建的SoapMessage中获取特定的字段值。

这是我传入的肥皂消息,

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

现在,我想获取“property1”文件,我该怎么做,我只能看到getHeaders(),getContextualProperty()等等

谢谢!

1 个答案:

答案 0 :(得分:0)

也许这个链接可以帮到你:

How to parse SOAP message into Jaxb classes

Jaxb是处理XML文档的框架,因为sopa body是XML,您可以使用Jaxb处理它