1

我需要删除以下soap request 中的所有命名空间前缀“bim”。我如何在soap处理程序handleMessage中做到这一点?

<bim:AuthorizationInfo>
    <!--Optional:-->
    <bim:ApplicationId>123</bim:ApplicationId>
    <!--Optional:-->
    <bim:UserId>123</bim:UserId>
    <!--Optional:-->
    <bim:Userid>123</bim:Userid>
    <bim:Password>123</bim:Password>
</bim:AuthorizationInfo>

此代码不起作用:

SOAPMessage soapMsg = context.getMessage();
SOAPEnvelope envelope = soapMsg.getSOAPPart().getEnvelope();
javax.xml.soap.SOAPBody body = envelope.getBody();
@SuppressWarnings("rawtypes")
Iterator iter = body.getChildElements();
while (iter.hasNext()) {
    Object object = iter.next();

    if (object instanceof SOAPElement) {
        SOAPElement element = (SOAPElement) object;
        element.removeNamespaceDeclaration(element.getPrefix());
        element.setPrefix("");
    }
}
4

0 回答 0