Java WebService 簡單實例

Java WebService 簡單實例

原文地址:http://www.cnblogs.com/yisheng163/p/4524808.html?utm_source=tuicool

前言:朋友們開始以下教程前,請先看第五大點的注意事項,以避免不必要的重複操作。

 

一、準備工作(以下爲本實例使用工具)

1、MyEclipse10.7.1

2、JDK 1.6.0_22

 

二、創建服務端

1、創建【Web Service Project】,命名爲【TheService】。


id="iframe_0.7013103279569235" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7887/2c2b9a5b-8476-3cc6-ae28-91affd0ae861.png?_=0.6674711404432478%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7013103279569235',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.40729904278192564" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7889/9f5965f0-fe48-317e-8db9-68dcc19abd8c.png?_=0.4801264501649032%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.40729904278192564',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

2、創建【Class】類,命名爲【ServiceHello】,位於【com.hyan.service】包下。


id="iframe_0.060439890493821036" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7891/156170f0-f6a7-3abe-bff8-4ee88633418c.png?_=0.16693111714682218%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.060439890493821036',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.6334456716073549" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7893/d31a1ebd-1607-3193-811e-5d1b27ef251a.png?_=0.5408517330954621%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6334456716073549',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

3、編寫供客戶端調用的方法,即編譯方法代碼。


id="iframe_0.4576240961439273" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7895/3324a266-78e2-3d27-a6ea-9e55e0e8403e.png?_=0.8932306157981278%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.4576240961439273',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

4、進行編譯

說明:編譯失敗的話,請將該項目引用的jdk設置爲1.6.0_17版本或更高版本


id="iframe_0.5558204178689943" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7897/03ee0b15-0e84-326c-a4ff-de4e729bdc76.png?_=0.1778664334241633%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5558204178689943',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.3416323456287864" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7899/5ea8baa7-3fca-3314-addc-ba0e9b101e9c.png?_=0.9474344380860413%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.3416323456287864',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

5、測試結果

測試地址:http://localhost:9001/Service/ServiceHello?wsdl


id="iframe_0.454913639381197" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7901/09b96287-a962-3fd7-bcf3-1c8ba19af4e7.png?_=0.6233658699505145%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.454913639381197',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

三、生成客戶端

1、創建【Web Service Project】,命名爲【TheClient】。


id="iframe_0.9227978042056411" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7903/23fe293c-5db1-3098-9ada-48c2c5f7f3f2.png?_=0.4881852805433917%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.9227978042056411',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.5224684816259115" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7905/0fe3b620-284d-3431-b322-29cd2292f6e6.png?_=0.943672762910192%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5224684816259115',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.06669214510027865" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7907/3b96eade-6324-33ad-85e9-9fba53866686.png?_=0.9776693682992748%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.06669214510027865',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

2、命令提示窗口執行生成命令。

格式:wsimport -s "src目錄" -p “生成類所在包名” -keep “wsdl發佈地址”

示例:

wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello?wsdl

說明:

1)"src目錄"地址不可含空格

2)“wsdl發佈地址”不要漏了“?wsdl”


id="iframe_0.6395458405528478" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7909/e01981dc-d50e-30d9-ba9f-e801d8a3361c.png?_=0.7467490231526792%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6395458405528478',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

3、刷新項目,檢查生成類


id="iframe_0.2295554700667093" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7911/44f65c4e-7e1a-3d22-9e38-5cc19974b457.png?_=0.20872185792915587%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2295554700667093',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.7718804402774344" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7913/03d1b9e5-4ab0-3f3b-a9a8-1753ccb4d4b2.png?_=0.2315806023215763%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7718804402774344',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
 

 

四、最終測試

1、創建【Class】類,命名爲【ServiceTest】,位於【com.hyan.test】包下。


id="iframe_0.04091145076964198" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7915/4a79b4a6-a3a3-3276-b47d-1dfe1e0839ff.png?_=0.9359682320340581%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.04091145076964198',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">

id="iframe_0.028849730135712015" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7917/73f2fb65-22ce-3d9d-8da8-00b987bb0fb1.png?_=0.4846745640372394%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.028849730135712015',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
  
id="iframe_0.5443425907460806" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7919/657933ba-9fcd-3f36-b1e7-e521be538df7.png?_=0.12721493467406053%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5443425907460806',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

2、編寫測試方法,調用服務端方法,並打印返回的結果。


id="iframe_0.22723454292746248" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7921/77e6b32d-d017-3127-9322-dde5a85b6966.png?_=0.454505790144057%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.22723454292746248',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.7418838956111526" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7923/1f61176d-25c9-346b-96f2-574c83e72b93.png?_=0.7110862935863986%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7418838956111526',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

五、注意事項

1、JDK版本過低問題

報類似如下的異常:runtime modeler error: Wrapper class com.hyan.service.jaxws.GetValue is not found. Have you run APT to generate them?


id="iframe_0.17473587928955703" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7928/389198e5-a59d-353e-8368-3c94a722ec67.png?_=0.6751187534224847%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.17473587928955703',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

原因:JDK版本低於1.6.0_17

解決方法:調整該服務端項目所引用的JDK版本爲安裝的高版本JDK


id="iframe_0.8250448965521235" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7930/9787565a-69f7-3f27-b780-0ff7e4a3393d.png?_=0.6915950927700021%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8250448965521235',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.026815159083855455" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7932/44b795ab-1558-33a4-a7e8-1e8e1f8c911a.png?_=0.2265425190102337%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.026815159083855455',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.8404547796294837" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7934/97e2942a-d21f-3ce2-b141-eedabe10d512.png?_=0.4556863053741813%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8404547796294837',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.8107746359568895" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7936/1ced02c9-945c-3ddb-9785-04c533c9f0b5.png?_=0.2221360082359587%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8107746359568895',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.2726179288903272" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7938/373d75b2-1c54-3bb7-91e9-35be5d77f98e.png?_=0.1688992708920971%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2726179288903272',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.8447864276343222" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7940/7e755db6-e732-3b14-bfbf-145812163f2f.png?_=0.6077112942615988%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.8447864276343222',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.5676579678649816" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7942/216b9ca3-0621-33f9-b962-df6fd0875da8.png?_=0.9920780295604466%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.5676579678649816',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.2574486608842319" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7944/d9831e5d-4b6e-31d9-ae0f-48e1ff39e6a9.png?_=0.08452512662065259%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.2574486608842319',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.9460312707227199" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7946/50eac14c-8b20-3c62-ac31-459e8b39997b.png?_=0.09999195244584813%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.9460312707227199',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.6538055583405709" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7948/d5662634-0f70-3d25-831d-e00af5e5162a.png?_=0.8174599708485097%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.6538055583405709',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 
id="iframe_0.695396117099301" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7950/ce7642b6-7c84-3f4f-8f55-36959d05b68c.png?_=0.10854033730027246%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.695396117099301',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

 

2、生成命令路徑含空格問題

報類似如下的異常:directory not found: G:\SVN_FILE\GB\05


id="iframe_0.7143874015288942" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7952/455c809d-3cc9-352a-aaee-d381f4a3f5df.png?_=0.8250296784697229%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.7143874015288942',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

原因:客戶端src路徑不可含有空格

解決方法:在不含空格路徑的文件夾下重新創建客戶端即可。

 

3、生成命令不完整問題

報類似如下的異常:[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s):


id="iframe_0.3944558187911005" src="data:text/html;charset=utf8,%3Cimg%20id=%22img%22%20src=%22http://dl2.iteye.com/upload/attachment/0101/7954/fef0cef5-b44b-35bb-9f69-5fcdd23d835d.png?_=0.9930695942824652%22%20style=%22border:none;max-width:1611px%22%3E%3Cscript%3Ewindow.onload%20=%20function%20()%20%7Bvar%20img%20=%20document.getElementById('img');%20window.parent.postMessage(%7BiframeId:'iframe_0.3944558187911005',width:img.width,height:img.height%7D,%20'http://www.cnblogs.com');%7D%3C/script%3E" frameborder="0" scrolling="no" style="box-sizing: border-box; border-style: none; border-width: initial; width: 1611px;">
 

原因:生成命令末尾缺少“?wsdl”

解決方法:補上即可。

錯誤不完整的命令示例:

wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello

正確完整的命令示例:

wsimport -s G:\\workspace\\webService\\TheClient\\src -p com.hyan.client -keep http://localhost:9001/Service/ServiceHello?wsdl

發佈了30 篇原創文章 · 獲贊 31 · 訪問量 19萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章