`
xueyong
  • 浏览: 60514 次
  • 来自: ...
社区版块
存档分类
最新评论

构建xfire动态client

    博客分类:
  • jave
阅读更多

1.创建一个java project,命名为XFireClient。

2.把xfire所有jar包加入到该工程的构建目录中。

3.创建一个类com.ws.client.Test,内容为:

java 代码
  1. package com.ws.client;   
  2.   
  3. import java.net.URL;   
  4.   
  5. import org.codehaus.xfire.client.Client;   
  6.   
  7. public class Test {   
  8.   
  9.     /**  
  10.      * @param args  
  11.      */  
  12.     public static void main(String[] args) {   
  13.         DyClient();   
  14.     }   
  15.        
  16.     /**  
  17.      * You get a DynamicClient when you create a Client with the URL of a WSDL  
  18.      */  
  19.     public static void DyClient(){   
  20.         try{   
  21.             Client client = new Client(new URL("http://localhost:8080/xfirews/services/MathService?WSDL"));   
  22.   
  23.             Object[] results = client.invoke("add"new Object[] {new Integer(1), new Integer(2)});   
  24.   
  25.             System.out.println((Integer) results[0]);   
  26.                
  27.         } catch(Exception e){   
  28.             e.printStackTrace();   
  29.         }   
  30.     }   
  31. }   

4.启动xfire start里创建的服务,运行该测试程序(调用服务MathService),返回3。

分享到:
评论
1 楼 map612 2012-08-22  
拉出去斩了,这也太次了吧

相关推荐

Global site tag (gtag.js) - Google Analytics