我正在尝试使用教程为 Soap 服务开发消费者
http://cxf.apache.org/docs/developing-a-consumer.html
在“使用上下文设置连接属性”部分中,我正在查看下面的代码
// Set request context property.
java.util.Map<String, Object> requestContext =
((javax.xml.ws.BindingProvider)port).getRequestContext();
requestContext.put(ContextPropertyName, PropertyValue);
// Invoke an operation.
port.SomeOperation();
有人可以告诉我是否可以使用 requestContext 属性设置代理服务器设置以及如何设置?。我的代码在代理后面运行,我需要传出 SOAP 调用才能使用代理服务器设置。
最佳答案
代理设置通常使用 httpconduit 对象设置
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");
关于java - Apache CXF 客户端代理设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31550064/