axis2 调用.net基于https的WebService接口
一、创建证书
1,在IE中访问WSDL的URL,弹出“安全警报”窗口,查看证书->详细信息标签页->复制到文件->下一步->下一步->指定文件名,将证书下载保存为.cer文件,例如:test_axis.cer
2,用下载到的证书文件生成信任库文件:
>keytool -import -file test_axis.cer -storepass changeit -keystore client.truststore -alias serverkey -noprompt
3,在调用WebService代码前指定信任库文件的路径:
System.setProperty("javax.net.ssl.trustStore", "/tmp/client.truststore");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
然后在java调用代码中加入
二、调用执行
package kind.util; import java.util.Iterator; import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient; public class WebServiceUtil { private static EndpointReference targetEPR = new EndpointReference(
"https://XXXXXX/IXXX.asmx?wsdl");// 接口WebService地址 public static void main(String[] args) {
try { System.setProperty("javax.net.ssl.trustStore", "D://client.truststore");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); OMFactory fac = OMAbstractFactory.getOMFactory(); OMNamespace omNs = fac.createOMNamespace(
"http://tempuri.org/", "tns");// 命名空间 // 请求参数设置
Options options = new Options();
options.setTo(targetEPR);// 设定webservice地址
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);// 设定传输协议
options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);// 设定SOAP版本soap1.2 // 客户端绑定参数设置
ServiceClient sender = new ServiceClient();
sender.setOptions(options); // 设定访问的接口方法 OMElement method = fac.createOMElement("Authorization", omNs);// 要调用的接口方法名称 OMElement value1 = fac.createOMElement("username", omNs);// 方法的第一个参数名称
value1.addChild(fac.createOMText(value1, "username"));// 设定参数的值
method.addChild(value1);// 方法设置参数 OMElement value2 = fac.createOMElement("password", omNs);// 方法的第一个参数名称
value2.addChild(fac.createOMText(value2, "password"));// 设定参数的值
method.addChild(value2);// 方法设置参数 OMElement result = sender.sendReceive(method);// 调用接口方法
Iterator iterator = result.getChildrenWithLocalName("AuthorizationResult");
System.out.println("guid="+((OMElement)iterator.next()).getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}
axis2 调用.net基于https的WebService接口的更多相关文章
- 业务逻辑:完成客户下单后前台系统的数据处理并调用后台系统服务处理业务 webservice接口调用 有用
思路: 页面提交表单后,在Action类中将页面提交的参数进行组装,随后通过使用Webservice技术来远程调用后台系统的业务接口服务来进行订单的保存操作 操作步骤: 在前台系统的Action类中通 ...
- java获取https网站证书,附带调用https:webservice接口
一.java 获取https网站证书: 1.创建一个java工程,新建InstallCert类,将以下代码复制进去 package com; import java.io.BufferedReader ...
- axis2调用webservice教训
总结教训,axis2client调用WS接口时url不能加?wsdl,而用cxf调用时则要加上. 今天用axis2的RpcServerClient调用https的webservice接口,在设置完op ...
- python发布及调用基于SOAP的webservice
现如今面向服务(SOA)的架构设计已经成为主流,把公用的服务打包成一个个webservice供各方调用是一种非常常用的做法,而应用最广泛的则是基于SOAP协议和wsdl的webservice.本文讲解 ...
- Webservice接口和Http接口
WebService又是一种高级应用,与之前学习的Struts.Spring.Hibernate等框架不同.WebService是面向服务的架构(SOA),看起来像是比SSH框架要大.那么它到底是做什 ...
- 基于Axis1.4的webservice接口开发(接口调用)
基于Axis1.4的webservice接口开发(接口调用) 一.webservice接口代码参考上一篇博客: http://www.cnblogs.com/zhukunqiang/p/7125668 ...
- Https Webservice接口的免证书调用
目录 前言 思路 方案 Axis调用 HttpClient调用 参考链接 前言 在调用https协议的Webservice接口时,如果没有做证书验证,一般会报javax.net.ssl.SSLHand ...
- 基于 Axis2的webService接口的基本开发步骤
Axis2webServicejavaWeb 前言: 今天给大家分享一下前段时间在做项目的时候做webservice接口的一些心得. 在web工程lib目录下导入 Axis2相关jar包 enter ...
- Java 常调用的Webservice接口的方法
WebService是基于Web的服务,WebService使用SOAP协议实现跨编程语言和跨操作系统平台,接收和响应外部系统的某种请求,从而实现远程调用.WebService采用HTTP协议传输数据 ...
随机推荐
- 周末充电之WPF(二 ) .窗口的布局
登录窗口布局:[ Grid 布局 -Grid.RowDefinitions / Grid.ColumnDefinitions] 代码如下: <Window x:Class="login ...
- 时间处理总结(一).net
不断整理中... 获取当前时间DateTime.Now.ToString("d") ;//获取到的日期格式为eg :2013/11/14 时间格式只取年月日DateTime.Now ...
- WPF简单拖拽功能实现
1.拖放操作有两个方面:源和目标. 2.拖放操作通过以下三个步骤进行: ①用户单击元素,并保持鼠标键为按下状态,启动拖放操作. ②用户将鼠标移到其它元素上.如果该元素可接受正在拖动的内容的类型,鼠标指 ...
- Name control
static: (Page 406) In both C and C++ the keyword static has two basic meanings, which unfortunately ...
- c#根据文件大小显示文件复制进度条实例
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- 访问Access数据库(有多个数据库时 体现多态)
如果想编写单机版MIS.小型网站等对数据库性能要求不高的系统,又不想安装SQLServer,可以使用Access(MDAC),只要一个mdb文件就可以了.使用Access创建mdb文件,建表.OleD ...
- 如何使用Json-lib
数组与List.Collection等都用JSONArray解析 boolean[] boolArray = new boolean[]{true,false,true}; JSONArray jso ...
- scala - 从合并两个Map说开去 - foldLeft 和 foldRight 还有模式匹配
开发中遇到需求:合并两个Map集合对象(将两个对应KEY的值累加) 先说解决方案: ( map1 )) ) } 这特么什么鬼 (╯‵□′)╯""┻━┻☆))>○<) ...
- C语言库函数--操作文件
//C库函数读取文件的代码 I/O缓冲机制 C语言库函数写文件都是写在内存中,然后一次写入磁盘.提高了效率. 读写文件,不对系统进行操作,一般采用C语言库函数.移植可以在任何可以对C支持的操作系统,而 ...
- yii2源码学习笔记(十)
继续了解Application. /** * Registers the errorHandler component as a PHP error handler. * 注册errorHandler ...