使用Eclipse內建Web Service外掛程式(Axis1.4)產生Web Service服務端/用戶端

來源:互聯網
上載者:User

JDK版本:1.5.0_22

Eclipse版本:Helios Service Release 2(3.6.2)

WSDL檔案的建立過程見http://blog.csdn.net/a19881029/article/details/24625429

建立一個名字為math的Java web工程,並將WSDL檔案拷入該工程中

將Axis所需的jar包拷貝至WebRoot\WEB-INF\lib目錄下,這些jar包會自動匯入math工程中

一,產生Web Service服務端

選中MathImpl.wsdl檔案右鍵->Web Services->Generate Java Bean Skeleton

僅僅產生Web Service服務端代碼即可,伺服器選擇Tomcat 6.0,Web Service環境選擇Apache Axis,服務工程選擇math工程,選擇完成後點擊“下一步”:

 然後選擇Web Servic服務端代碼的產生路徑,選擇完成後點擊“下一步”:

只產生Web Service服務端代碼,並不進行部署,這裡直接點擊“完成”即可

此時可以發現在math工程中自動產生了Web Service服務端的代碼和部署/解除檔案

只需編寫MathImplSoapBindingImpl檔案中的服務端具體處理過程即可: [java]  view plain copy /**   * MathImplSoapBindingImpl.java   *   * This file was auto-generated from WSDL   * by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.   */      package com.sean.ws;      public class MathImplSoapBindingImpl implements com.sean.ws.MathImpl{       public int plus(int a, int b) throws java.rmi.RemoteException {           //return -3;           int c = a + b;           System.out.println("The result is:" + c);           return c;       }   }  

 

二,產生Web Service用戶端

選中MathImpl.wsdl檔案右鍵->Web Services->Generate Client

 只產生Web Service用戶端代碼,選擇完成後點擊“下一步”:

然後選擇Web Servic用戶端代碼的產生路徑,選擇完成後點擊“完成”:

此時可以發現在math工程中自動產生了Web Service用戶端代碼

直接使用MathImplProxy類即可: [java]  view plain copy package com.sean.ws;      import java.rmi.RemoteException;      public class Test {       public static void main(String[] args) throws RemoteException {           MathImplProxy proxy = new MathImplProxy();           proxy.plus(1, 2);       }   }  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.