Skip to main content
 首页 » 编程设计

xml之用于 SOAP 响应的 Mule Xpath

2025年12月25日25jyk

我有以下肥皂响应,我想使用 xpath 从 xml 获取状态值。

soap:Envelope 
soap:Body 
ProcessMTUConsignmentSourceResponse xmlns="http://www.compdata.com.au/" 
ProcessMTUConsignmentSourceResult 
ConnoteSourceImportResponse xmlns="" 
ProcessTime 2014-05-29T22:12:50+1000 ProcessTime 
Status Success Status 
Message Connote Import Success Message 
ConnoteSourceImportResponse 
ProcessMTUConsignmentSourceResult 
ProcessMTUConsignmentSourceResponse 
soap:Body 
soap:Envelope 
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
将命名空间添加到 mule 配置文件,如下所示

有人可以帮我吗。

请您参考如下方法:

从 XML 中获取状态的 Mule XPATH 表达式如下

#[xpath('//comp:ProcessMTUConsignmentSourceResponse/comp:ProcessMTUConsignmentSourceResult/comp:ConnoteSourceImportResponse/comp:Status').text] 

在此之前将命名空间添加到 Mule 命名空间管理器
<mule-xml:namespace-manager> 
    <mule-xml:namespace prefix="soap" 
        uri="http://www.w3.org/2003/05/soap-envelope" /> 
    <mule-xml:namespace prefix="comp" 
        uri="http://www.compdata.com.au/" /> 
</mule-xml:namespace-manager> 

希望这可以帮助。