webservice如何设置代理服务
2016-05-13 13:54
447 查看
由于最近有客户需通过webservice接入我们这边的系统(Axis21.3),以前给接入包不行,问了客户那边的情况才知道他们那边是内网通过代理访问外网的。
以前的client是通过插件自动生成的,所以直接在生成的stub类里面加上配置代理的参数就ok
Java代码
![](http://jophy.iteye.com/images/icon_star.png)
/**
* Constructor that takes in a configContext and useseperate listner
*/
public MessageTransportServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext,
java.lang.String targetEndpoint, boolean useSeparateListener)
throws org.apache.axis2.AxisFault {
//To populate AxisService
populateAxisService();
populateFaults();
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
configurationContext = _serviceClient.getServiceContext().getConfigurationContext();
_serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
targetEndpoint));
_serviceClient.getOptions().setUseSeparateListener(useSeparateListener);
//以下为通过配置文件判断是否使用代理,有使用的话设置参数
Configuration config=new Configuration();
if (config.getValue("isproxy").equals("true")) {
ProxyProperties proxyProperties=new ProxyProperties();
proxyProperties.setProxyName(config.getValue("host"));
proxyProperties.setProxyPort(Integer.valueOf(config.getValue("port")));
proxyProperties.setDomain(config.getValue("domain"));
proxyProperties.setUserName(config.getValue("username"));
proxyProperties.setPassWord(config.getValue("userpassword"));
_serviceClient.getOptions().setProperty(HTTPConstants.PROXY, proxyProperties);
_serviceClient.getOptions().setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_10);
}
}
webservice是通过http端口走的,所以代理应该提供http端口,一开始客户提供了socks5端口,害的测试n久都没通过
转载自:http://jophy.iteye.com/blog/441372
以前的client是通过插件自动生成的,所以直接在生成的stub类里面加上配置代理的参数就ok
Java代码
![](http://jophy.iteye.com/images/icon_star.png)
/**
* Constructor that takes in a configContext and useseperate listner
*/
public MessageTransportServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext,
java.lang.String targetEndpoint, boolean useSeparateListener)
throws org.apache.axis2.AxisFault {
//To populate AxisService
populateAxisService();
populateFaults();
_serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service);
configurationContext = _serviceClient.getServiceContext().getConfigurationContext();
_serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(
targetEndpoint));
_serviceClient.getOptions().setUseSeparateListener(useSeparateListener);
//以下为通过配置文件判断是否使用代理,有使用的话设置参数
Configuration config=new Configuration();
if (config.getValue("isproxy").equals("true")) {
ProxyProperties proxyProperties=new ProxyProperties();
proxyProperties.setProxyName(config.getValue("host"));
proxyProperties.setProxyPort(Integer.valueOf(config.getValue("port")));
proxyProperties.setDomain(config.getValue("domain"));
proxyProperties.setUserName(config.getValue("username"));
proxyProperties.setPassWord(config.getValue("userpassword"));
_serviceClient.getOptions().setProperty(HTTPConstants.PROXY, proxyProperties);
_serviceClient.getOptions().setProperty(HTTPConstants.HTTP_PROTOCOL_VERSION, HTTPConstants.HEADER_PROTOCOL_10);
}
}
webservice是通过http端口走的,所以代理应该提供http端口,一开始客户提供了socks5端口,害的测试n久都没通过
转载自:http://jophy.iteye.com/blog/441372
相关文章推荐
- 依附品牌做代理 把握创业新机遇
- 代理区独立模式的说明
- http代理相关知识分析
- 为MySQL安装配置代理工具Kingshard的基本教程
- ASP.NET WebService中使用ASP.NET_SessionId的问题说明
- JavaScript的事件代理和委托实例分析
- ASP调用WebService转化成JSON数据,附json.min.asp
- js调用webservice构造SOAP进行身份验证
- ajax跨域调用webservice的实现代码
- php的webservice的wsdl的XML无法显示问题的解决方法
- PHP调用Webservice实例代码
- asp代理采集的核心函数代码
- 在PHP中利用wsdl创建标准webservice的实现代码
- JQuery调webservice实现邮箱验证(检测是否可用)
- WebService出现"因 URL 意外地以 结束,请求格式无法识别"的解决方法
- 用JavaScript调用WebService的示例
- nginx 1.0.0配ngx_cache_purge实现高效的反向代理
- jQuery调用WebService返回JSON数据及参数设置注意问题
- 同步调用和异步调用WebService
- C#调用WebService实例开发