JaxwsDynamicClientFactoryを使用してhttps Webサービスを呼び出し、Webサービスssl証明書が自己署名されているため、次のコードを使用してsslチェックを回避します。JaxwsDynamicClientFactoryがWebサービスを呼び出せません
String wsUrl = "https://218.17.179.67:8443/QhicPos/doService?wsdl";
String method = "doPosRequest";
QName qName = new QName("http://service.pos.qhic.com/", method);
HttpsURLConnection.setDefaultSSLSocketFactory(TrustAnyFactory.getInstance().getSslContext().getSocketFactory());
HostnameVerifier allHostsValid = (hostname, sslSession) -> true;
// Install the all-trusting host verifier
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance();
Client client = clientFactory.createClient(wsUrl);
HTTPConduit conduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
conduit.getClient().setReceiveTimeout(0);
httpClientPolicy.setConnectionTimeout(6000000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(6000000);
conduit.setClient(httpClientPolicy);
try {
Object[] rst = client.invoke(qName, new Object[]{xmlRequest});
System.out.println(rst[0].toString());
} catch (Exception e) {
e.printStackTrace();
}
が、私はコードを呼び出すときに私は、私は例外が発生しました:私は混乱して作る
org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
Waring: Interceptor for {http://service.pos.qhic.com/}PosServiceImplService# {http://service.pos.qhic.com/}doPosRequest has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Operation timed out
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:108)
at org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:324)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:277)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:297)
at HttpsWebServiceClient.getClient(HttpsWebServiceClient.java:65)
at HttpsWebServiceClient.main(HttpsWebServiceClient.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: com.ctc.wstx.exc.WstxIOException: Operation timed out
at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:255)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:106)
... 14 more
Caused by: java.net.ConnectException: Operation timed out
...
は、私はもちろん、SOAPメッセージを(送信するためにHttpPostを使用する場合、私はいくつかのワーク・を使用したことですSSL検証をスキップするために)、正常に応答を返すことができますが、JaxwsDynamicClientFatoryを使用して動的クライアントを生成すると失敗します。
これは、コードのssl回避策に関するものですか?
誰でも手伝ってもらえますか?どうもありがとう。
必要とされている
私は、Webサービスは、IPフィルタリングを使用していることに気づきました 接続の外に – user2605926