通过代理调用webservice服务

由于最近有客户需通过webservice接入我们这边的系统(Axis21.3),以前给接入包不行,问了客户那边的情况才知道他们那边是内网通过代理访问外网的。
以前的client是通过插件自动生成的,所以直接在生成的stub类里面加上配置代理的参数就ok

/**
* 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久都没通过
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值