java - Apache CXF 客户端代理设置

标签 java apache web-services soap cxf

我正在尝试使用教程为 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/

相关文章:

java - 在 centos 中为 Oracle JDBC jar 设置类路径

java - 通过条件查找ArrayList中的元素并通过lambda返回他或null

wcf - 您可以将泛型与 Web 服务一起使用吗?

c# - 使用ajax的跨服务器web服务

java - Java中的分页sql表

java - Apache-Kafka-Connect 、 Confluence-HDFS-Connector 、 未知魔法字节

apache - Apache Tika 能够提取中文、日语等外语吗?

php - 连接到 mysql 服务器(本地主机)非常慢

Apache - 如何限制文件的最大下载速度? (如果不是 apache,我可以运行 lighthttpd)

java - 如何通过 WebSocket 响应 Web 服务请求