0
我使用Axis 1.4,并且我想在客户端中的SOAP主体的XML中插入额外的级别。有一个服务器响应,我可以用javax.xml.rpc.handler.GenericHandler的客户端中的子类得到:更改SOAP处理程序中的XML结构
现在,我尝试用
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage message = smc.getMessage();
SOAPBody sb = message.getSOAPBody();
NodeList nl = sb.getElementsByTagName("projectDataReturn");
if (nl.getLength() == 0) {
return true; // wrong message
}
log.info("we have a projectDataReturn structure");
NodeList cl = sb.getElementsByTagName("centres");
if (cl.getLength() == 0) {
return true; // no centres
}
log.info("we have centres tags");
在此认识到正确的信息类型点我需要一个新的标签,其中包含所有现有的<centres>
标签。已存储在cl
中的所有<centres>
标记的列表已经存在,但我如何将新节点添加到<projectDataReturn>
标记?以及如何将现有<centre>
标签移动到新标签?我曾与
Document doc = cl.item(0).getOwnerDocument();
Element array = doc.createElement("centres");
array.setAttribute("xmlns:ns5", "http://beans.eo.xyz.de");
array.setAttribute("soapenc:arrayType", "ns5:CentreBean[" + cl.getLength() + "]");
array.setAttribute("xsi:type", "soapenc:Array");
array.setAttribute("xmlns:soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
nl.item(0).appendChild(array);
// move existing <centre> tags here
return true;
尝试过,但它产生的SoapException
javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Could not get document from SOAPEnvelope
有什么不对?