實現(xiàn)多個參數(shù)的調(diào)用_第1頁
實現(xiàn)多個參數(shù)的調(diào)用_第2頁
實現(xiàn)多個參數(shù)的調(diào)用_第3頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、西北工業(yè)大學(xué)電子服務(wù)系統(tǒng)設(shè)計 實驗報告學(xué) 院: 學(xué) 號: 姓 名: 專 業(yè): 實驗時間: 實驗地點: 指導(dǎo)教師:、實驗?zāi)康募耙缶毩?xí)如何在web服務(wù)實現(xiàn)類中接受多個參數(shù)二、實驗設(shè)備(環(huán)境)及要求1、PC機最低配置:2G Hz以上CPU 1G以上內(nèi)存;1G自由硬盤空間2、JDK1.5.03、Eclipse4、Axis2三、實驗內(nèi)容與步驟1、在web服務(wù)實現(xiàn)類中接受多個參數(shù)。2、互用性。四、實驗結(jié)果與數(shù)據(jù)處理因為這個 web service 是文檔類型的,在輸入消息(Input message)包含一 個part。因此在服務(wù)實現(xiàn)類中對應(yīng)一個參數(shù)。對于輸出消息也是類似的。在消息 中,若依然是接受一個

2、part(<c on catRequest>)。如果實現(xiàn)多個參數(shù),僅僅需要對WSD文件作兩個地方的修改:上r -S<xsd! oli -iiKMit 山"kofigt石匕tump LexType><xsd:sequences甘<xsd:Elenin± n* type-J,jcsd: string*/>9ID<xsd: element ntype- ''xsd: string*/11 :12 </x*;ci; comp pxTypp>13 </xsd: plpiicni|>1 A -<

3、;xckd: '11 in* t nnni0» "concatRe sponsc " t y"xstf; strifig ">17 </xsd:schein>IS </wsdl:typcs>19: iicssdgE? iM(ne= 'corttalHespon *F>崔r(nóng)i. ridme= Hpurometers " e lement= " tns; conceit Response ,r>21 </wsdllpart>22 </wsdl:messa

4、ge>? <wsdl znessage name=-conc3tRequie5trt>.<|.-.,r.Hl :卩.irt namp= nrgwptFrs " elempnt= tnironcat1?5 </wsdli part>*£AD«i尹 | Em ii ft#對于output message 道理也是類似的,元素名必須是操作名加上后綴Response”并且元素必須是一個序列(sequenee):發(fā) SimpleSefvice.rtdl 遼4-sc Ilyina target Namespace ''htt

5、p:/t tdeu. com/ssy<xsd:plpaipni- namp= VpjQrt?r,r>|2:4<xsd: h!ejient jin川片IS116</(1:plpmont >|17 </xsd: sctiema>18</wsdl:types>19- <hisdl:message name=,rcongtfiE年的_ ?0-<wsdl:part nane-"paratneters" &lement= 'tnsconcotRsponse"21</w<>dl:

6、 pdrt>12</wsdlr me&sage>23- oi&dl :ntesage name= ,rconcatRequest24- <ubdl: par L name-rp(jrume ttrsfl elerrienl=f,(/7b: concot">25 </wsdl:part>26 </wsdl:rnessage>27-<wsdl:portType name=MSiffipteServiceM>18-?<ws>dlopcrmtiDD naika=,Yurrcat,*>29-&l

7、t;wsdl: input message=Ktnsr<?oncatffewest*>36</wsdl:input>31<wsdl:output iitassag9=dVns;tponse">接下來進行驗證,拷貝工程SimpleService 并保存為工程 WrappedServiee.刪除所有的Java文件?!?out ”文件夾依然鏈接到原來的位置 (E:axis2-162-b in axis2-162repositoryservicesSimpleService).切換到eclipse 導(dǎo)航視圖并打開.project文件。把.project文件

8、中的路徑改為E:axis2-1.6.2-bi naxis2-1.6.2repositoryservicesWrappedService:4< comment >c/c Dement >勺丁<proj&cts>6</prDjects >7-<tiulld5pei>fi-<buildComik<nHd>9< tw mn - org. i p嶼p. j dr -. j own bui 1 dr< : n * * >u</argu*nenits>12< /bu ildc onnand &

9、gt;13</bulldsp&c>14-<riatLires>15<ri.itiir&Jorg-eclip5e+jdt B core+j avnature</ma t ure >I右</natures>1 #cltnk«lfle5txirc«>IS"<llnk>19<rK 川虻 >0utp</iijn?o< type > 2</type >Zlclrrt5晉卩pedSer/1口于門卄 l =口?2J? 3c/linkedResource

10、s>茨</project&escription>25把文件SimpleService.wsdl 重命名為 WrappedService.wsdl并做以下修改:,J dpneityf-ixt flrtdl I:4=1 12 Cwlidl"JCTiln :tn*:ttp:/ttdv.tcmi/ssJ| xmlns:vrtcILhttp:".xtMog.oriji/wiidA/J'4 MHilrii:丫賓1=州燈門:/|«札肪?<rhrt?i3n iiiaerwMService"|“i遛電tw誦*吟網(wǎng)Whrg:|歸 &l

11、t;tr5d l: types><xc;dl:5ChR?i3 tangeTNinespace= "Mnfpr/ttde冒.row/5.5">A<xd:eltii£rit riJiM-,Ci3ncat">胃cxsds complexType 3-電、|1&<»vd - lrnnt 們孑鬧三勺廠 type = *xs d; s tr izrf H/>11<x d -1 r- iir-nT naiyn52#, type="x>d>?$trf州7ff></注rl

12、;巳 1 仲一“r >17</xsdiequnce>13< / scsd: c-onp 1 exT ype >14</xsd2 element>zn»e= cone ute spouse >16<M%d: ccsmfilexTyp>17CMid:18oMcleiwnt n«w=Vn typ=-*xscJ/str 1 rr" />19</xsd4equence>20c/srsd: co«p 1 町 T ype >2122< /xsd: scheina>23<

13、;/ws41: types->更改 build.xml:崔huM wrl哉T < xml versiGn=,l»0*' encodingUTF'S"xproject bsedir=*'." default=2 34£6S910 n 121314<I-Auto generatad ant build <property <property qr opprty <property 卩roperty <property qr operty <property <property &l

14、t;property <property <propertyenvironnient=°env't/> nam- ridirie- naine- t泊電一 ndine= HdlTI" n白亡二 naie=axis2.home" value=H$(env*AX3S2 HOME"/> project<hsp*d訃"vaup="."/> maven .class *pdLh" narneH, #詡丄日!jd電dbgr中icb1src" value-"$pro

15、ject«basedlr/scc"f> test1' value= r$prDject»base,dir/test7> build" value=*'project. base.dir/buildw/> classes" value-TSfbuild-/classesi/> lib" value=l1$build/lib*/> resources" value=T'Spraje匚t*b35e*dLr/e50ur(:E5 jars.ok" value=>&l

16、t;target nat)e="generate-service">114-<wsdl2code111- |116 serverside="true"117 enerateservicexml=H truert11RskiphuiIdxml'+rup"119servers ide interface-"true''120121122123124126-128129132131namepacetopackages-"http: /ttdev.cofr/s-CDiii. ttd&v.

17、ss* target&ourcefolderlocation-'src'targetreso urc esfolderloc at ion'15 rc/META' IMF "/><target name-Flgpneratp -' 1 ipnt '><wsdl2codehisdl Tilendme'Jriainu .wsdl" | skipbuilclxmltrue"ndmespaetcpackages="http: /ttdww .coiVsghCcxn. ttd電

18、“ * target source-Folderlocation-" src"tar got re sou rce sf oldo r location=" &rc /N ETA INF'1 verwr i.te-" truF,r / ></target>接下來我們需要一個特殊的service stub來執(zhí)行一些特殊的處理操作。當一 個concat元素到來時,service stub 將從concat元素中獲得 s1和s2兩 個元素,并把這兩個參數(shù)作為兩個參數(shù)的值(這個功能成為解封 裝”nwrapping ”當服務(wù)返回一

19、個字符串,service stub將把這個返回值作為r元素的值,并且把r元素放入到concatResponse元素中(這個功能稱為圭寸 裝 wrapping ):2 Fxtract <si >, rtom <concat> use it parameters1. Do the same tting for <s2>.into <co<icatResponse> This is called "wrapping"這里需要注意的是,這個service依然是一個文檔類型的service 。客戶端依 然用相同的方式對其調(diào)用(除了

20、 concatRequest改為了 concat).不同的是service stub調(diào)用你的實現(xiàn)并且如何處理返回值。這些不同對客戶端來說是透明 的。為了生成這樣的 service stub,需要在 Ant任務(wù)wsdl2code加上選項:勒 build.xml 埜=B丄JL J116J. H 丄丄上| IdJIlt 山 1 IcdHIK J *丄servers ide-true1'117gpnpratpsprvi rpxml=Huf"11S119serversldeinterfacG=H true"n a me sp/ cetopdckdge 3-*' htt

21、p; /ttdev* com/ sscoiw.ttdev ss1*121targetsourcpfo Up"122target r esou rces-fb Ider loc at ion-" sr c /ME T A INI "123overwrite= true"124|u nwr a p="true"1257>126</target>127-<tareet"generate-client >12S-細 sdl2"dg12Siftjsdlfilename-"$name.w

22、sdl"skipbuildxml1true*1131namespacetopackage&=,Thttp: / ttdev, com/ss=com ttdev«132targetsourcefolderlocation='src"133targetresourcesfolderlocation- -src/ML FA-INK"134overwrite=" true*R135136/>< 1>運行 build.xml文件生成 service stub 和 client stub。BUC提示:在 Axis21.3中有一個bug阻止任務(wù)wsdl2code覆蓋文件services.xml.所以首先把文件 services.xml 刪除然后再運行 build.xml ,刷新工程。檢查WrappedServiceSkeleton .java:public class Wr'dppdSericSke丄utun ltnplmerits Ar'dppedScriLeSkL!丄eLuh丄film廣十心.牡public String concatfString sll, String s22)LJ然后創(chuàng)建一個實現(xiàn)類WrappedServiceImpI:public class WrappedServi

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論