cxf方式

public static Object[] invokeRemoteMethod(String url, String method, Object[] parameters) {
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
if (!url.endsWith("wsdl")) {
url += "?wsdl";
}
org.apache.cxf.endpoint.Client client = dcf.createClient(url);
try {
Object[] objects = client.invoke(method, parameters);
return objects;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

maven引用

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-core -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.1.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.5</version>
</dependency>

缺点是效率低,调用速度慢

Xfire方式调用

public static String getData(String wsUrl, String invoke, Object[] objParams) throws MalformedURLException, Exception {
URL url = new URL(wsUrl);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.connect();
Client client = new Client(connection.getInputStream(), (Class)null);
client.setProperty("disable-keep-alive", "true");
client.setProperty("disable.expect-continue", "true");
client.setUrl(wsUrl);
Object[] result = client.invoke(invoke, objParams);
String resultStr = result[0].toString();
return "".equals(resultStr)?"":resultStr;
}

maven引用

 <dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-all</artifactId>
<version>${xfire.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>

缺点是jar包太旧了,很容易与其他包冲突

最新文章

  1. 使用react做的聊天对话列表
  2. BI的相关问题[转]
  3. Android Genymotion无法启动
  4. Oracle11g中Exp命令空表不能导出的问题
  5. 利器: 用Siege做Web服务器压测
  6. Redis常用数据类型
  7. 可爱的PYTHON,更新到0.5版本代码
  8. 用户登陆,退出等基本Action
  9. Oracle运维 专业的事情交给专业的人来做
  10. Web API-路由(二)
  11. HDU 1589 Find The Most Comfortable Road 最小生成树+枚举
  12. SQLite高级:一库建多表,封装类
  13. Swift3中数组创建方法
  14. Linux在VirtualBox的网络设置
  15. elasticsearch简单操作(一)
  16. 使用sshfs挂载远程服务器目录
  17. Redhat 简单本地yum 配置
  18. Android Activity传递数据使用getIntent()接收不到,揭秘Intent传递数据与Activity启动模式singleTask的关系。
  19. logstash获取日志,时间戳相差8小时
  20. iPhone激活策略说明

热门文章

  1. AC自动机 HDU 2222
  2. orcle函数的使用,及其调用
  3. crodova打包apk个人总结
  4. git: 修改commiter 信息
  5. 数据结构作业——Sanji(优先队列)
  6. linux下mnt目录作用
  7. Nuget Command Console
  8. maven log4g 用法
  9. JavaScript中的私有属性
  10. CentOS / Redhat : Configure CentOS as a Software Router with two interfaces