sts 创建webservice项目_Eclipse Maven生成WebService客户端代码及测试
條件:
1. Eclipse安裝Axis2插件
2. 導入Web Service相關包
創建Maven項目
導入axis2相關jar包
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0?http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.soap
soap
0.0.1-SNAPSHOT
soap-client
dom4j
dom4j
1.6.1
org.apache.axis2
axis2-adb
1.7.1
wsdl詳情
生成Web Service客戶端代碼:
即生成客戶端代碼
生成客戶端代碼測試案例:package?com.soap.client;
import?java.net.MalformedURLException;
import?java.net.URL;
import?java.rmi.RemoteException;
import?org.apache.axis.AxisFault;
import?cn.com.tech_trans.www.CRM_VIP_ProxyLocator;
import?cn.com.tech_trans.www.CRM_VIP_ProxySoapStub;
import?cn.com.tech_trans.www.ResponseDataOfBasicInfo;
/**
*客戶端測試代碼
*?@author?Roger
*/
public?class?ClientTestGetBasicInfo?{
public?static?void?main(String[]?args)?throws?Exception?{
try?{
//?服務端Service
CRM_VIP_ProxyLocator?service?=?new?CRM_VIP_ProxyLocator();
//?服務端web?service?的wsdl地址
URL?endpointURL?=?new?URL("http://-------:1999/CRM_VIP_Proxy.asmx?WSDL");
//?通過wsdl地址與service獲取Proxy
CRM_VIP_ProxySoapStub?stub?=?new?CRM_VIP_ProxySoapStub(endpointURL,
service);
//?調用接口
ResponseDataOfBasicInfo?basicInfo?=?stub.getBasicInfo();
//?響應信息
System.out.println(basicInfo);
}?catch?(AxisFault?e)?{
e.printStackTrace();
}?catch?(MalformedURLException?e)?{
e.printStackTrace();
}?catch?(RemoteException?e)?{
e.printStackTrace();
}
}
}
當需要調用其他接口,只需要將相應的調用接口換掉就可以
測試結果六月?30,?2016?11:05:26?上午?org.apache.axis.utils.JavaUtils?isAttachmentSupported
警告:?Unable?to?find?required?classes?(javax.activation.DataHandler?and?javax.mail.internet.MimeMultipart).?Attachment?support?is?disabled.
cn.com.tech_trans.www.ResponseDataOfBasicInfo@739feed3
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的sts 创建webservice项目_Eclipse Maven生成WebService客户端代码及测试的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常用的DDOS攻击流量处置方法(防止dd
- 下一篇: 泸州房地产备案(泸州房备案)