Eclipse + Apache AXIS2 Tips

Version

JDK 1.6.0_45

AXIS2 1.6.2

Tomcat 6.0.32

Environment Setup

Step 1: Download Axis2 Binary Distribution and extract to a directory, such as C:\axis2-1.6.2.

Step 2: Download Tomcat and extract to a directory, such as C:\tomcat-6.0.32.

Step 3: Set Environment Variables

(Win7)

Open 電腦→內容→進階系統設定→環境變數→系統變數→Add JAVA_HOME=C:\Java\jdk1.6.0_45

Open 電腦→內容→進階系統設定→環境變數→系統變數→Add AXIS2_HOME=C:\axis2-1.6.2

Step 4: Set Eclipse Workspace Encoding.

Open Eclipse→Window→Preferences→General→Workspace→Text file encoding→UTF-8

Step 5: Set Eclipse Axis Runtime.

Open Eclipse→Window→Preferences→Web Services→Axis2 Preferences→Axis2 runtime location=指向Axis2目錄 (Step 1所建立的目錄)

Open Eclipse→Window→Preferences→Web Services→Server and Runtime→Web service runtime=Apache Axis2

Open Eclipse→Window→Preferences→Web Services→Scenario Defaults→Client generation level設到Assemble client就好

Step 6: Set Tomcat Runtime.

Open Eclipse→Window→Preferences→Server→Runtime Environments→Add Apache Tomcat→選取Tomcat installation directory=指向Tomcat目錄 (Step 2所建立的目錄)

WebService Client Project

Step 1. Open Eclipse→New→Java Project→Create a folder: wsdl→存放backend WSDL file

Step 2. Right click on a WSDL file→Web Services→Generate Client→Service runtime: Tomcat v6.0 Server; Web service runtime: Apache Axis2; Client project: 新增一WebApp (Dynamic Web Project) or 選一個既存的WebApp→Next→確認Port Name (如果有多個Port Name)→Finish. 基本上會建立出2個Class: XXXCallbackHandler & XXXSub

Step 3. Code snippet

String URL = "http://IP:Port/...";
XXXStub stub = new XXXStub(URL);
......
[response] resp = stub.operator([request]);
......

Reference

http://www.eclipse.org/webtools/community/tutorials/BottomUpAxis2WebService/bu_tutorial.html

https://docs.oracle.com/cd/E21764_01/web.1111/e13734/clients.htm#WSADV584

http://www.ibm.com/support/knowledgecenter/SS8S5A_6.2.0/com.ibm.curam.content.doc/WebServices/c_WEBSERV_Connectors2CreatingClientInvokingWebService1.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s