2017-06-02 84 views
0

我想使用java將下面的xml請求發送到ESB端點http://abc.co.za:8000/service/abcdefg。我不是很熟悉Web服務和ESB,因爲我來自Front End。使用java發送xml請求到遠程服務

任何幫助或建議,將不勝感激。

Server Time: 11:02:58:028/Workstation Time: Monday, 22 February 2016 - 11:02:57:703 
[DEBUG] SENDING SOAP REQUEST 
MethodID: ID_getSubmitRequest; UID=-4820428854312736237 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> 
<soapenv:Body> 
<ns2:getSubmitRequest xmlns:ns2="urn:AC_IDM_SUBMITREQUESTVi" xmlns="urn:com.virsa.ae.ejbutil"> 
<ns2:requestDetails> 
<application/> 
<company>STACK OVERFLOW</company> 
<customField> 
<CustomFieldsDTO> 
<name>Users ID Number</name> 
<value>6303066107089</value> 
</CustomFieldsDTO> 
</customField> 
<department xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<emailAddress>[email protected]</emailAddress> 
<employeeType>STACK</employeeType> 
<firstName>RONNY</firstName> 
<functionalArea xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<lastName>RONNY</lastName> 
<locale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<location xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<managerTelephone xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<mgrEmailAddress xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<mgrFirstName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<mgrId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<mgrLastName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<priority>HIGH</priority> 
<requestReason xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<requestType>SYSTEM</requestType> 
<requestorEmailAddress>None</requestorEmailAddress> 
<requestorFirstName>None</requestorFirstName> 
<requestorId>BP5151</requestorId> 
<requestorLastName>None</requestorLastName> 
<requestorTelephone>None</requestorTelephone> 
<roles> 
<RoleData> 
<action>ADD</action> 
<comments xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<roleId>ZCB_STACK</roleId> 
<sysId/> 
<validFrom>2016-02-22T11:02:57+02:00</validFrom> 
<validTo>9999-02-22T11:02:57+02:00</validTo> 
</RoleData> 
</roles> 
<sNCName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/> 
<telephone></telephone> 
<unsecureLogon>false</unsecureLogon> 
<userId>BP111</userId> 
<validFrom>2016-02-22T11:02:57+02:00</validFrom> 
<validTo>9999-02-22T11:02:57+02:00</validTo> 
</ns2:requestDetails> 
</ns2:getSubmitRequest> 
</soapenv:Body> 
</soapenv:Envelope> 

回答

1

有多個庫可以幫助您完成此任務。其中一個選項是Apache CXF:http://cxf.apache.org/docs/wsdl-to-java.html

步驟來完成這個任務:

  • 使用Apache CXF或其他圖書館創建包含代碼連接到目標SOAP服務
  • 你的Java代碼,這個庫/項目的客戶機JAR
  • 初始化代理以連接到服務(由生成的客戶端庫提供)
  • 填充輸入
  • 調用SOAP端點和進程輸出的調用返回

很好的例子證明了這一點:http://cxf.apache.org/docs/developing-a-consumer.html