4
votes

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.

1

1 Answers

13
votes

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