0
這就是我想要的:SOAP - 無前綴命名
<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中*創建SOAP消息。 ..我無法找到一個方法只在param標籤中插入前綴。
這是生成SOAP消息的代碼:
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");
我能做些什麼,只除去命名空間?
您發佈的xml格式不正確。無論如何,嘗試替換_messageBody.addChildElement(method,PREFIX); _ with _messageBody.addChildElement(envelope.createName(method,PREFIX,getNameSpace(method))); _ – 2013-03-14 15:20:56
感謝您的幫助...... mhhmh..na !. ...一樣的 -_-'.... – Ging3r 2013-03-14 15:44:34