Apache CXF客户端代理设置

ave*_*t12 3 java apache soap web-services cxf

我正在尝试使用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();
Run Code Online (Sandbox Code Playgroud)

有人能告诉我是否可以使用requestContext属性设置代理服务器设置以及如何?我的代码在代理后面运行,我需要支出SOAP调用来使用代理服务器设置.

Aur*_*oto 11

代理设置通常使用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");
Run Code Online (Sandbox Code Playgroud)