1

我想摆脱静态的“ims:”并将 SOAP 请求中的前缀与 namespace 一起使用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>
4

1 回答 1

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();
            }
    }
}
于 2013-04-09T20:52:13.493 回答