67,513
社区成员
发帖
与我相关
我的任务
分享
public class SurveyServiceClient
{
public static void main(String[] args)
{
System.setProperty("javax.net.ssl.keyStore", "G:/SSL/keystore/client.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "client");
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("javax.net.ssl.trustStore", "G:/SSL/keystore/tomcat.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "testpass");
// 加载客户端的配置定义
ApplicationContext context = new
ClassPathXmlApplicationContext("beanRefClient.xml");
// 获取定义的 Web Service Bean
ISurveyService surveyService =
(ISurveyService)context.getBean("surveyServiceClient");
// 1、定义调查投票的变量与内容,用来发送给服务
String username = "Test";
int point = 88;
// 调用方法进行服务消费
String result = surveyService.vote(username,point);
System.out.println("Result:" + result);
// 2、传递不一样的调查投票内容
username = "Michael";
point = 100;
// 再次调用方法进行服务消费,得到不一样的结果
result = surveyService.vote(username,point);
System.out.println("Result:" + result);
// 3、第三次传递与调用
username = "Jordan";
point = 9;
result = surveyService.vote(username,point);
System.out.println("Result:" + result);
}
}
org.apache.cxf.interceptor.Fault: Could not send Message.
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:532)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:464)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:367)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:320)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:89)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134)
at $Proxy31.vote(Unknown Source)
at ws.cxf.client.SurveyServiceClient.main(SurveyServiceClient.java:26)
Caused by: javax.net.ssl.SSLHandshakeException: SSLHandshakeException invoking https://localhost:8443/WSDemo/SurveyWebService: java.security.cert.CertificateException: No X509TrustManager implementation available
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.mapException(HTTPConduit.java:1458)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1443)
at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:659)
at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
... 9 more
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No X509TrustManager implementation available
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
String serviceURL = "https://localhost:8443/httpsxfire/services/HelloWebService";
System.setProperty("javax.net.ssl.keyStore", "d:/lcl.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "aaaaaaa");
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("javax.net.ssl.trustStore", "d:/tomcat.keystore");
System.setProperty("javax.net.ssl.trustStorePassword", "aaaaaaa"); Service serviceModel = new ObjectServiceFactory().create(IHelloWebService.class);
IHelloWebService service=null;
try {
service = (IHelloWebService) new XFireProxyFactory().create(serviceModel, serviceURL);
} catch (MalformedURLException e) {
logger.error("初始化xx网webService失败," + e);
}
System.setProperty("javax.net.debug", "all");
System.err.println(service.sayHello("杨mmm"));