Web Service Development - 2

This article will show you the simple way to develop a client class to call web services.

 

step 1. download standard binary distribution.

 

if your OS is vista, select control panel - system - Advanced system settings, go to 'advanced' tab and click 'Environment  Variables...'

 

set AXIS2_HOME as the axis2 installation folder for the binary distribution.

 

Note: this step can not be skipped.

 

step 2. run this command in windows command window

 

C:/Users/andy>%AXIS2_HOME%/bin/wsdl2java -uri http://localhost:8080/axis2/services/SimpleService?wsdl -p client -s -o stub

 

-p: package name

-o: root folder for client source code

 

in my computer, the response message is as follows.

 

Using AXIS2_HOME:   E:/axis2-1.4.1
Using JAVA_HOME:    C:/jdk1.6.0_13
Retrieving document at 'http://localhost:8080/axis2/services/SimpleService?wsdl'

 

so you can find client source code C:/Users/andy/stub/src/client/SimpleServiceStub.java

I will not list the source code for this class. it's a little long and complicated.

 

 Step 3. create a client class to call above SimpleServiceStub.java.

StubClient.java
package
 client;

public class StubClient {

public static void main(String [] args) throws Exception {
SimpleServiceStub stub = new SimpleServiceStub();
SimpleServiceStub.GetGreeting gp = new SimpleServiceStub.GetGreeting();
gp.setName("bill gates" );
System .out.println(stub.getGreeting(gp).get_return());
System .out.println(stub.getPrice().get_return());
}
}

run this class, you will see the result returned from web service.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值