XFire技術(shù)文檔.docx_第1頁(yè)
XFire技術(shù)文檔.docx_第2頁(yè)
XFire技術(shù)文檔.docx_第3頁(yè)
XFire技術(shù)文檔.docx_第4頁(yè)
全文預(yù)覽已結(jié)束

下載本文檔

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

文檔簡(jiǎn)介

XFire技術(shù)文檔一、 需要的類庫(kù).activation-1.0.2.jar commons-codec-1.3.jar commons-httpclient-3.0.jar commons-logging-1.0.4.jar jaxen-1.1-beta-8.jar jdom-1.0.jar log4j-1.2.x.jar mail-1.3.3_01.jar spring-1.2.x.jar stax-api-1.0.jar wsdl4j-1.5.2.jar wstx-asl-2.9.jar xbean-2.1.0.jar xbean-spring-2.2.jar xfire-all-1.0.jar XmlSchema-1.0.jar二、 類文件IBankingService、BankingService、AccessSer三、 源代碼。1. IBankingServicepackage com.mybank.xfire.example;public interface IBankingService public String transferFunds( String fromAccount, String toAccount, double amount, String currency); 2. BankingServicepackage com.mybank.xfire.example;import java.text.NumberFormat;import java.text.DecimalFormat;public class BankingService implements IBankingService public String transferFunds( String fromAccount, String toAccount, double amount, String currency) String statusMessage = ; try NumberFormat formatter = new DecimalFormat(#,#,#,#.00); statusMessage = COMPLETED: + currency + + formatter.format(amount)+ was successfully transferred from A/C# + fromAccount + to A/C# + toAccount; catch (Exception e) statusMessage = BankingService.transferFunds(): EXCEPTION: + e.toString(); return statusMessage; 3. AccessSerpackage it.luzhrong.client;import java.io.IOException;import java.io.PrintWriter;import .MalformedURLException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import mons.logging.Log;import mons.logging.LogFactory;import org.codehaus.xfire.XFire;import org.codehaus.xfire.XFireFactory;import org.codehaus.xfire.client.XFireProxyFactory;import org.codehaus.xfire.service.Service;/注意此類所在的包import org.codehaus.xfire.service.binding.ObjectServiceFactory;import com.mybank.xfire.example.IBankingService;public class AccessSer extends HttpServlet protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException / TODO Auto-generated method stubdoGet(arg0, arg1);protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException / TODO Auto-generated method stub/super.doGet(request, response);try String result=callWebService(request.getParameter(from),request.getParameter(to),Double.parseDouble(request.getParameter(amt) ,request.getParameter(cur);PrintWriter pw=response.getWriter();pw.write(result); catch (Exception e) e.printStackTrace();public String callWebService( String fromAccount, String toAccount, double amount, String currency)throws MalformedURLException, Exception /Create a metadata of the service Log log = LogFactory.getLog(AccessService.class); Service serviceModel = new ObjectServiceFactory().create(IBankingService.class); log.debug(callSoapServiceLocal(): got service model. ); /Create a proxy for the deployed service XFire xfire = XFireFactory.newInstance().getXFire(); XFireProxyFactory factory = new XFireProxyFactory(xfire); String serviceUrl = http:/localhost:8080/xFire/services/Banking; IBankingService client = null; try client = (IBankingService) factory.create(serviceModel, serviceUrl); catch (MalformedURLException e) log.error(WsClient.callWebService(): EXCEPTION: + e.toString(); /Invoke the service String serviceResponse = ; try serviceResponse = client.transferFunds(fromAccount, toAccount, amount, currency); catch (Exception e) log.error(WsClient.callWebService(): EXCEPTION: + e.toString(); serviceResponse = e.toString(); log.debug(WsClient.callWebService(): status= + serviceResponse); /Return the response return serviceResponse; 四、 配置文件Web.xml、services.xml(此文件所在的目錄為/web-inf/classes/META-INF/xfire 路徑不能錯(cuò),否則找不到)五、 配置內(nèi)容4. Web.xml acServiceit.luzhrong.client.AccessSer XFireServlet XFire Servlet org.codehaus.xfire.transport.http.XFireConfigurableServlet acService/server/* XFireServlet /servlet/XFireServlet/* XFireServlet /services/* 5. Services.xml Banking mybank com.mybank.xfire.example.IBankingService com.mybank.xfire

溫馨提示

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

評(píng)論

0/150

提交評(píng)論