这就是我要的:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tps="http://mysite.it">
<soapenv:Header/>
<soapenv:Body>
<tps:getBook>
<tps:id>45</tps:id>
</tps:Retrieve_getBook_Poi_Recordset>
</soapenv:Body>
</soapenv:Envelope>
但这是我有的:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tps="http://mysite.it">
<soapenv:Header/>
<soapenv:Body>
<tps:getBook xmlns:tps="http://mysite.it">
<tps:id xmlns:tps="http://mysite.it">45</tps:id>
</tps:Retrieve_getBook_Poi_Recordset>
</soapenv:Body>
</soapenv:Envelope>
我正在使用 javax.xml.soap.* 创建肥皂消息...我找不到在 param 标记中仅插入前缀的方法。
这是生成肥皂消息的代码:
MessageFactory msgFactory = null;
SOAPMessage message = null;
msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
message = msgFactory.createMessage();
SOAPEnvelope messageEnvelope = message.getSOAPPart().getEnvelope();
SOAPBody messageBody = messageEnvelope.getBody();
messageEnvelope.addNamespaceDeclaration(PREFIX, getNameSpace(method));
SOAPElement soapMethod = messageBody.addChildElement(method, PREFIX);
SOAPElement param = soapMethod.addChildElement("id",PREFIX);
param.addTextNode("45");
我该怎么做才能只删除命名空间?