如何删除名称空间前缀soap处理程序handleMessage

时间:2016-09-15 05:31:46

标签: soap jax-ws soaphandler

我需要删除所有命名空间前缀" 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("");
    }
}

0 个答案:

没有答案