好文收藏:使用 Apache Maven 和 CXF 构建 RESTful web services http://www.ibm.com/developerworks/cn/opensource/os-restfulwebservices/index.html
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 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.
java
apache
web-services
soap
cxf
asked Jul 21 '15 at 21:36
avenirit12 48 2 9
|
1 Answers
1
解决方法
Proxy setting are usually set by using httpconduit object首先从http://www.apache.org的网站上下载apache-2.2.0的源代码。apache-2.2.0的版本做了些改动大家需要注意一下。首先apr和apr-util需要单独的安装,还有配置文
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");
answered Jul 21 '15 at 22:35
Aurelien Ecoto 86 4 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 '{
cxf.apache.org}TransportURIResolver.http-conduit'.An afirmative Trust Decision is assumed. HTTPConduit:914-Conduit '{
cxf.apache.org}TransportURIResolver.http-conduit' has been (re)configured for plain http. HTTPConduit:378-NoTrust Decider configured for Conduit '{
cxf.apache.org}TransportURIResolver.http-conduit' HTTPConduit:391-NoAuth Supplier configured for Conduit '{
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
|
转自:http://www.celinio.net/techblog/p=571 The WSDL2java command generates JAX-WS compliant Java code for the services that are defined in the WSDL