用xfire开发webservice客户端

1、  安装jdk

jdk 1.6.0 _02

2、  安装tomcat

tomcat 5.5.20

3、  安装eclipse

下载eclipse3.2,并把他解压缩到d:/ECLIPSE目录

1>     安装tomcatPlugin插件:解压缩tomcatPluginV32.zip包,把解压缩的结果放入D:/eclipse/plugins目录

2>     安装resourcebundleeditor插件:解压缩ResourceBundleEditor_v 0.7.7 .zip包,然后把解压缩的结果放入D:/eclipse/plugins目录

重新启动eclipse/myeclipseresourcebundleeditor进行配置:

进入到eclipsewindow---preference里面,你可以看到下图

 

 

 

所示的界面,设置你自己想要的配置,然后完成,即完成配置

4、  安装myeclipse

myeclipse5.5

5、  将更新The XFire Eclipse plugin

The XFire Eclipse plugin provides Eclipse support for XFire's WSDL->Code generator. It requires Eclipse 3.2 and Java 5.

Installing the Plugin

To install the Eclipse XFire plugin:

go to the Help menu, select "Software Updates" and then select "Find and Install."

Select "Search for new features to install" and click Next.

Select "Create New Remote Site" and enter "XFire" as the name and http://dist.codehaus.org/xfire/update/ as the eclipse update site.

Select OK.

Select Finish

 

6、  新建一个web工程,把WSDL文件拷贝到SRC目录,右击WEB工程=>new=>other

7、  选择XFIRE文件夹下的code generation from wsdl document,点下一步按钮,出现以下对话框

8、  选择WSDL URL or path Output directory

9、  设置客户端代码所在的包

10、              单击完成按钮,完成客户端框架的生成

11、              下载XFIREJAR包:xfire-distribution- 1.2.6 解压缩到D

12、              添加xfireJAR

       鼠标指向工程,点右键,选择Build Path --àAdd Library

             

   选择User Libraries 点下一步:

      

User Libraries

新建用户库XFIRE,引入xfire-distribution- 1.2.6 lib目录下所有的JAR文件和xfire-all-1.2.6.jar,把该用户库引入到WEB工程

13、              src文件夹下建立testmain函数,测试webservice能否正常运行,如下:

       package cn.com.cmbc.emu.xi.transferdata;

 

import java.lang.reflect.Proxy;

import org.codehaus.xfire.client.Client;

import org.codehaus.xfire.client.XFireProxy;

 

 

public class testmain {

 

              /**

             * @测试webservice服务器端能否正常运行

             */

              public static void main(String[] args) {

              //预定义客户端输入对象

              CMBCLOSBPDT cmbcl;

       //建立客户端对象

CMBC_LOSTST_OUTServiceClient client =new CMBC_LOSTST_OUTServiceClient();

//建立服务器端对象

       CMBC_LOSTST_OUT service = client.getCMBC_LOSTST_OUTPort();

//引入org.codehaus.xfire.client.Client包,设置认证用户名和密码

Client client1 = e((XFireProxy)Proxy.getInvocationHandler(service)).getClient();

client1.setProperty(client1.getOutChannel().USERNAME, "user");   client1.setProperty(client1.getOutChannel().PASSWORD,"111111");

//根据ObjectFactory类,创建客户端输入对象

       ObjectFactory of = new ObjectFactory() ;

       cmbcl=of.createCMBCLOSBPDT();        

        //设置输入对象中属性的值

       cmbcl.setBUSINESSPARTNER("aaaaaaaaaa");

       //得到webservice的返回对象的name属性

        System.out.println(service.cMBC_LOSTST_OUT(cmbcl).getNAME());

       System.out.println("test client completed");

       }

}

14、              运行上程序,如果能在控制台打印出name属性的值,那么webservice调用成功

 

说明:可以把testmain类改造成javabean,实现webservice客户端与web工程的集成,即在IE中动态设置调用对象的值,并显示webservice的返回结果,在集成过程中要注意,JSP页面和javabean之间最好是以对象为单位传值,即JSP传给Javabean客户端输入对象,Javabeanwebservice服务器端交互后,返回服务器端返回对象,JSP解析返回对象

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值