2013-04-21 47 views
1

我在Eclipse中使用JDOM完成了許多集成,但第一次遇到問題,因爲我的SOAP XML消息應包含元素wuth特定元素並且包含HEADER元素。這是我的整個消息:Java - 使用JDOM創建Web服務請求 - 標題問題

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:agi="http://agilent.parlayx.sms"> 
    <soapenv:Header> 
     <cppass>test</cppass> 
     <cpuname>test</cpuname> 
    </soapenv:Header> 
    <soapenv:Body> 
     <agi:sendBulkSms> 
      <address>tel:3876123456</address> 
     </agi:sendBulkSms> 
    </soapenv:Body> 
</soapenv:Envelope> 

我創建使用此BODY結構:

Element top = new Element("sendBulkSms", agi); 
Document jDoc = new Document(top); 

Element address = new Element("address", agi); 
address.setText("tel:3876123456"); 
top.addContent(address); 

這工作好,我以前做過很多次。但有沒有可能創建消息uisng JDOM的頭部元素或不是?因爲據我所知唯一可以定義BODY元素,但隨後我的消息不會是有效的Web服務請求

謝謝你,我會感謝幫助

+0

你在用什麼web服務引擎? – 2013-04-21 21:56:33

+0

集成通過WebSphere Application Server完成 – 2013-04-21 22:05:39

+0

那麼爲什麼不使用WAS WS Engine?編碼和維護會更容易。 – 2013-04-21 23:50:46

回答

0

你只是創建標準的XML沒有「頭「你只需要一個名爲」Header「的元素,命名空間=」soapenv「。所以在我看來,它應該像創建任何其他JDOM元素一樣。