2015-07-21 180 views
1

我想在 http://cxf.apache.org/docs/developing-a-consumer.html的Apache CXF客户端代理设置

在部分开发使用教程SOAP服务消费者,“设置与上下文连接属性”我在看下面的代码

// 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调用来使用代理服务器设置。

回答

9

代理设置,通常使用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"); 
+0

这样做,在运行一个简单的单元测试来ping我没有得到任何错误的服务,但测试被卡住,并保持对这些打印控制台 – avenirit12

+0

HTTPConduit:1740-No信任决策者为Conduit'{http://cxf.apache.org} TransportURIResolver.http-conduit'。假定为肯定的信任决策。 HTTPConduit:914-Conduit'{http://cxf.apache.org} TransportURIResolver.http-conduit'已被重新配置为纯http。 HTTPConduit:为Conduit配置的378-NoTrust Decider'{http://cxf.apache.org} TransportURIResolver.http-conduit' HTTPConduit:391-NoAuth为Conduit配置的供应商'{http://cxf.apache.org} TransportURIResolver.http-conduit'已配置为纯http。 – avenirit12

+1

我认为问题在发生,因为SOAP调用终于在https上调用服务,而不是http – avenirit12