【文章內(nèi)容簡(jiǎn)介】
va工具該工具的命令有:Usage WSDL2Code uri : WSDL file locationo : output file locationa : Generate async style code only. Default is offs : Generate sync style code only. Default is off. takes precedence over ap : set custom package namel : valid languages are java and csharp. Default is javat : Generate TestCase to test the generated codess : Generate server side code (. skeletons). Default is offsd : Generate service descriptor (. ). Default is off. Valid with ssd : valid databinding(s) are adb, xmlbeans and jaxme. Default is adbg Generates all the classes. valid only with the sspn : name of port in the presence of multiple portssn : name of service in the presence of multiple servicesu : unpacks the databinding classesr : path of the repository against which code is generated在windows平臺(tái)下可以用WSDL2Java uri ../samples/wsdl/ ss sd d xmlbeans o ../samples p 在Linux平臺(tái)下可以用WSDL2Java uri ../samples/wsdl/ ss sd d xmlbeans o ../samples p 于是生成了服務(wù)的代碼框架,在代碼框架中填入代碼第三部分:用Axis2創(chuàng)建服務(wù)客戶端服務(wù)可以完成各種各樣的功能,有的簡(jiǎn)單,時(shí)間消費(fèi)比較低,有的復(fù)雜,時(shí)間消費(fèi)比較高。我們不能采用一個(gè)統(tǒng)一的機(jī)制來(lái)調(diào)用這些時(shí)間消費(fèi)區(qū)別很大的服務(wù)。例如:我們用HTTP協(xié)議來(lái)帶調(diào)用一個(gè)INOUT類型的服務(wù),而這個(gè)服務(wù)的執(zhí)行時(shí)間很長(zhǎng),于是我們可能得到一個(gè)connection time out的結(jié)果。而且,在一個(gè)客戶端同時(shí)發(fā)出兩個(gè)服務(wù)調(diào)用請(qǐng)求的情況下,使用’blocking’的客戶端API將降低客戶端程序的性能。類似的,當(dāng)我們使用OneWay傳輸?shù)臅r(shí)候還可能有很多其他的后果產(chǎn)生。Blocking API:當(dāng)服務(wù)調(diào)用請(qǐng)求發(fā)出后,客戶端等待服務(wù)結(jié)果的返回,這期間不能再發(fā)出服務(wù)調(diào)用請(qǐng)求。NonBlocking API:這是一個(gè)基于callback或者polling的API,讓客戶端發(fā)出服務(wù)調(diào)用請(qǐng)求的時(shí)候,客戶端程序立刻得到控制權(quán),服務(wù)的調(diào)用結(jié)果由callback對(duì)象來(lái)接收。這樣,客戶端就可以同時(shí)調(diào)用多個(gè)服務(wù)而不進(jìn)行阻止。Axis將利用NonBlocking API方式的異步叫做API Level Asynchrony前面提到的兩個(gè)機(jī)制在Request和Response上使用了一個(gè)的傳輸連接,他們限制了服務(wù)調(diào)用在請(qǐng)求與結(jié)果返回使用兩個(gè)傳輸連接的情況( either OneWay or TwoWay )所以這兩種機(jī)制都無(wú)法解決在長(zhǎng)時(shí)間運(yùn)行的事務(wù)中的尋址問題(傳輸連接可能在操作結(jié)束前就已經(jīng)timeout了)。一種解決方案是在request和response中使用兩個(gè)不同的傳輸連接。在這個(gè)級(jí)別上得到的異步屬性,稱為Transport Level Asynchrony將前面的2種異步結(jié)合起來(lái),就有了四種不同的調(diào)用模式服務(wù)的調(diào)用代碼:blocking invocationtry {OMElement payload = ()。Options options = new Options()。(targetEPR)。 // this sets the location of MyService serviceServiceClient serviceClient = new ServiceClient()。(options)。OMElement result = (payload)。(result)。} catch (AxisFault axisFault) {()。}INONLYtry {OMElement payload = ()。Options options = new Options()。(targetEPR)。ServiceClient serviceClient = new ServiceClient()。(options)。(payload)。/**We have to block this thread untill we send the request , the problemis if we go o