通过http代理远程调用webservice SOA
程序员文章站
2022-06-08 11:04:57
...
从局域网远程调用外网的webservice服务提供的操作。贴出代码片段。我用的是xfire
/** * 获取Client对象实例并设置http代理 * @return Client * @throws Exception */ public Client getClient() throws Exception { String proxyHost = "代理ip"; String proxyPort = "代理端口"; System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", proxyHost); System.getProperties().put("proxyPort", proxyPort); Client client = new Client(new URL(URL)); client.setProperty(client.getOutChannel().USERNAME, "代理上的用户名"); client.setProperty(client.getOutChannel().PASSWORD, "代理上的密码"); // client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, "300"); client.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE, "true"); client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "true"); client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, "代理ip"); client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, "代理端口"); client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_USER, "代理上的用户名"); client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PASS, "代理上的密码"); return client; }
上一篇: 一个初级应届毕业生(初级程序员)的茫然
下一篇: 我的她,你在哪?