Java - 使用JDOM创建Web服务请求 - 标题问题
问题描述:
我在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服务请求
谢谢你,我会感谢帮助
答
你只是创建标准的XML没有“头“你只需要一个名为”Header“的元素,命名空间=”soapenv“。所以在我看来,它应该像创建任何其他JDOM元素一样。
你在用什么web服务引擎? – 2013-04-21 21:56:33
集成通过WebSphere Application Server完成 – 2013-04-21 22:05:39
那么为什么不使用WAS WS Engine?编码和维护会更容易。 – 2013-04-21 23:50:46