【发布时间】:2010-11-12 13:10:23
【问题描述】:
我必须编写一个通用模板来从肥皂响应中查找操作名称和命名空间。我的意思是通用的,适用于任何操作。所以我不知道操作名称和命名空间名称,但想在发送响应时获取它们并修改回来。
这是响应的结构:
类型1:操作的命名空间定义在<soapenv:Envelope>:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:inf="http://bad.com/abc/infrastructure"
xmlns:ret="http://bad.com/FirstOperationToExecute"
xmlns:com="http://bad.com/commercial">
<soapenv:Header/>
<soapenv:Body>
<ret:retrieveSummaryRequest>
<!-- ... result ... -->
</ret:retrieveSummaryRequest>
</soapenv:Body>
</soapenv:Envelope>
类型2:在元素<ret:retrieveSummaryRequest>中定义的命名空间:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:inf="http://bad.com/abc/infrastructure"
xmlns:ret="http://bad.com/FirstOperationToExecute"
xmlns:com="http://bad.com/commercial">
<soapenv:Header/>
<soapenv:Body>
<ret:retrieveSummaryRequest xmlns:ret="http://bad.com/FirstOperationToExecute" >
<!-- ... result ... -->
</ret:retrieveSummaryRequest>
</soapenv:Body>
</soapenv:Envelope>
类型 3:<retrieveSummaryRequest> 中的默认命名空间:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:inf="http://bad.com/abc/infrastructure"
xmlns:ret="http://bad.com/FirstOperationToExecute"
xmlns:com="http://bad.com/commercial">
<soapenv:Header/>
<soapenv:Body>
<retrieveSummaryRequest xmlns="http://bad.com/FirstOperationToExecute" >
<!-- ... result ... -->
</retrieveSummaryRequest>
</soapenv:Body>
</soapenv:Envelope>
谁能帮我看看是否有一个简单的 XPath 语句来获取操作名称和命名空间。
【问题讨论】:
标签: xml xpath namespaces