我想摆脱静态“ims:”并使用SOAP请求中找到的带有命名空间xmlns:ims="http://www.imsglobal.org/services/lis/bdems1p0/wsdl11/sync/imsbdems_v1p0
的前缀。我怎么能在Spring拦截器中做到这一点?
protected String findProperty(SOAPHeader soapHeader, String propertyName) {
NodeList list = soapHeader.getElementsByTagName("ims:" + propertyName);
我想要的属性是
<ims:imsx_syncRequestHeaderInfo>
<ims:imsx_version>V1.0</ims:imsx_version>
<ims:imsx_messageIdentifier>?</ims:imsx_messageIdentifier>
</ims:imsx_syncRequestHeaderInfo>
答案 0 :(得分:1)
修正了以下内容。
NodeList nodeList = soapHeader.getElementsByTagName("*");
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE
&& node.getLocalName().equalsIgnoreCase(propertyName)) {
if (node.getTextContent().isEmpty()) {
return null;
} else {
return node.getTextContent();
}
}
}