5

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.

avenirit12
  • 233
  • 2
  • 5
  • 17

1 Answers1

17

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");
Aurelien Ecoto
  • 206
  • 2
  • 5
  • Did that , while running a simple unit test to ping the service I don't get any errors but the test is stuck and keeps printing these on the console – avenirit12 Jul 22 '15 at 14:06
  • HTTPConduit:1740-No Trust Decider for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit'.An afirmative Trust Decision is assumed. HTTPConduit:914-Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit' has been (re)configured for plain http. HTTPConduit:378-NoTrust Decider configured for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit' HTTPConduit:391-NoAuth Supplier configured for Conduit '{http://cxf.apache.org}TransportURIResolver.http-conduit' has been configured for plain http. – avenirit12 Jul 22 '15 at 14:11
  • 1
    I think the problem is occurring because the SOAP calls are finally calling a service on https and not http – avenirit12 Jul 22 '15 at 14:19
  • To be clear for other readers: Credentials for `HTTPConduit.getProxyAuthorization()` are different from `HTTPConduit.getAuthorization()`. The first is for the (internet) proxy that allows connection to the remote server, and the second is used with the remote (SOAP?) service. – kevinarpe Dec 19 '17 at 08:04