WebService Interface Invocation Guide

Source: Internet
Author: User
Tags wsdl

Client development Steps (Java):

This example shows how to create a WebService client using AXIS2 in an Eclipse environment.

First, Environment preparation (if you already have a AXIS2 development environment, skip this step)

1. AXIS2 API Package

The AXIS2 version used in this example is 1.4, please download it at the following address:
Http://apache.mirror.phpchina.com/ws/axis2/1_4/axis2-1.4.1-bin.zip
Unzip the package to any directory after download. This package may be required if you want to develop directly using the AXIS2 API.

2. Axis2 Eclipse plug-in (code generation and packaging tools)

This example uses a plug-in version of 1.4, please go to the following address to download:
Packaging tools:
Http://apache.mirror.phpchina.com/ws/axis2/tools/1_4/axis2-eclipse-service-archiver-wizard-1.4.zip
Code Generation Tools:
Http://apache.mirror.phpchina.com/ws/axis2/tools/1_4/axis2-eclipse-codegen-wizard-1.4.zip

In fact, we only use the Code generation tool.

3. Installing the Axis2 Eclipse plugin

(1) Extract the downloaded Axis2 two plugins to the plug-in subdirectory under the Eclipse installation directory;

(2) under the/lib directory of the AXIS2 API installation directory, copy Backport-util-concurrent-3.1.jar and geronimo-stax-api_1.0_ Spec-1.0.1.jar these two files to the/plugins/axis2_codegen_wizard/lib directory of the Eclipse installation directory, and also to edit the Eclipse installation directory/plugins/axis2_codegen_ Plugin.xml under the wizard, add these two files (two in red):
<library name= "Lib/jibx-run-1.1.5.jar" >
<export name= "*"/>
</library>
<library name= "Lib/backport-util-concurrent-3.1.jar" >
<export name= "*"/>
</library>
<library name= "Lib/geronimo-stax-api_1.0_spec-1.0.1.jar" >
<export name= "*"/>
</library>
</runtime>

Then start Eclipse and select "File->new->other" to find the following two Wizards:
Axis2 Code Generator and Axis2 Service archiver indicate that the plug-in installation was successful.

Ii. development of the client

Open Eclipse, create a new Java project, and the JDK best chooses JDK1.5.

1. Select "Build classpathàadd Libraries ..." To add all the jar packages in the AXIS2 API installation directory/lib directory.

2. Create a new package, such as Com.yourcompany.client.

3. Using "Fileànewàother", select the Axis2 Code Generator plugin under the Axis2 Wizard in the Select Wizards window. Next.

4. Select "Generate Java source code from a WSDL file", Next.

5. Enter the WSDL access address in the WSDL file location, for example: HTTP://192.168.0.1/AXIS2/SERVICES/XXX?WSDL. Next.

6. Codegen option to choose Default. Next.

7, select the Output path, click "Browse and select a project on the current Eclipse workspace", then click the "Browse ..." button and select the project. Finish,codegen Plugin Generation Client Agent code complete

8. New test class, call WebService interface method. Instance code:

public class Orderserviceclient {
public static void Main (string[] args) throws axisfault{
Orderservicestub stub = new Orderservicestub ();
Test search by phone number for ordering information
Orderservicestub.getorderinfodfbyphone request = new Orderservicestub.getorderinfodfbyphone ();

Request.setphone ("15969000000");
Orderinfodf[] Result=null;
try{
Result=stub.getorderinfodfbyphone (Request). Get_return ();
}catch (Exception e) {
E.printstacktrace ();
}
if (result!=null) {
for (int i=0;i<result.length;i++) {
ORDERINFODF O=result[i];
System.out.println ("###################");
System.out.println ("Area code:" +o.getareaid ());
SYSTEM.OUT.PRINTLN ("Household Number:" +o.getcustomerid ());
System.out.println ("Order Status:" +o.getlastsendflag ());
System.out.println ("Last Send Time:" +o.getlastsendtime ());
SYSTEM.OUT.PRINTLN ("Order instruction:" +o.getorderaction ());
System.out.println ("Order Time:" +o.getordertime ());
System.out.println ("Mobile phone Number:" +o.getphone ());
System.out.println ("Name:" +o.getusername ());
}
}

}

The results of the operation are as follows:

###################

Area code: 0871

Account Number: 30200363

Order Status: 0

Last send time: 2008-12-29 15:39:38

Ordering instruction: df#30200363#0871

Order Time: 2008-07-30-15:07:46

Phone Number: 15969000000

Name: null

###################

WebService Interface Invocation Guide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.