avenirit12
avenirit12

Reputation: 243

Apache CXF Client proxy settings

I am trying to Develop a Consumer for Soap Service using the tutorial at http://cxf.apache.org/docs/developing-a-consumer.html

In the section ,"Setting Connection Properties with Contexts" I am looking at the code below

// 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();

Can someone tell me if I can set the proxy server settings using the requestContext properties and how ?. My code is running behind a proxy and I need the outgoings SOAP calls to use proxy server settings.

Upvotes: 6

Views: 18461

Answers (1)

Aurelien Ecoto
Aurelien Ecoto

Reputation: 226

Proxy setting are usually set by using httpconduit object

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");

Upvotes: 19

Related Questions