这个问题很大。没有简单的解决方案
我可以提供步骤和手册指南
1)解决CXF依赖项以在您的项目中包含库
使用Maven,Ivy或下载。您需要jax-ws和相关的 http://cxf.apache.org/docs/using-cxf-with-
maven.html
2)使用wsdl2java生成Java客户端到您的wsdl
例如
wsdl2java -p com.mycompany.greeting Greeting.wsdl
http://cxf.apache.org/docs/wsdl-to-
java.html
3)以编程方式创建jax-ws
wdsl2java已为您完成了工作 http://cxf.apache.org/docs/how-do-i-develop-a-
client.html#HowdoIdevelopaclient?-JAX-WSProxy
HelloService service = new HelloService();Hello helloClient = service.getHelloHttpPort();String result = helloClient .sayHi("Joe");注意:也可以通过弹簧进行配置
4)使用客户端证书配置身份验证
这是艰难的一步 http://cxf.apache.org/docs/client-http-transport-includes-ssl-
support.html#ClientHTTPTransport(包括SSLsupport)-配置SSLSupport
定义参考您的证书的管道文件。这是一个例子
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xmlns:sec="http://cxf.apache.org/configuration/security" xsi:schemaLocation="http://cxf.apache.org/transports/http/configurationhttp://cxf.apache.org/schemas/configuration/http-conf.xsdhttp://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"> <http-conf:conduit name="*.http-conduit"> <http-conf:tlsClientParameters disableCNCheck="true" secureSocketProtocol="TLS"> <sec:keyManagers keyPassword="password" > <sec:keyStore type="pkcs12" password="password" file="yourcertificate.p12" /> </sec:keyManagers> </http-conf:tlsClientParameters> <http-conf:client Connection="Keep-Alive" MaxRetransmits="1" AllowChunking="false" /> </http-conf:conduit></beans>
如果您喜欢以编程方式进行操作,则可以
Client client = ClientProxy.getClient(helloClient);HTTPConduit http = (HTTPConduit) client.getConduit();//set the parameters in a similar way to file



