2015-07-21 182 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