问题描述
我知道这不是提出问题的正确方法,但我遇到了问题:
I know this isn't exactly the correct way to ask a question, but I'm having a problem:
我在本地存储了一个wsdl,而且我需要创建一个Web服务客户端来调用该Web服务。问题是服务是在防火墙后面,我必须通过代理连接到它,然后我必须验证连接到WS。
I have a wsdl stored locally, and I need to create a Web Service Client to call that Web Service. The problem is the service is behind a firewall and I have to connect to it through a proxy and after that I have to authentify to connect to the WS.
我做了什么使用Apache CXF 2.4.6生成WS客户端然后设置系统范围的代理
What i did is generate the WS Client with Apache CXF 2.4.6 then set a system wide proxy
System.getProperties().put("proxySet", "true");
System.getProperties().put("https.proxyHost", "10.10.10.10");
System.getProperties().put("https.proxyPort", "8080");
我知道这不是最佳做法,所以请提出更好的解决方案,如果有人可以的话给我一个关于如何设置验证的提示我非常感激
I know this isn't a best practice, so please suggest a better solution, also if anyone can give me a tip on how to set the authentification I'dd really appreciate it
推荐答案
使用apache CXF
With apache CXF
HelloService hello = new HelloService();
HelloPortType helloPort = cliente.getHelloPort();
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(helloPort);
HTTPConduit http = (HTTPConduit) client.getConduit();
http.getClient().setProxyServer("proxy");
http.getClient().setProxyServerPort(8080);
http.getProxyAuthorization().setUserName("user proxy");
http.getProxyAuthorization().setPassword("password proxy");
这篇关于具有代理和Autentification的WS客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!