我正在尝试连接到SOAP网络服务器,我获得了证书,但我得到以下异常。 我做了:
$openssl pkcs12 -in cert.pfx -out certificate.cer -nodes
$keytool -import -alias webserver -file certificate.cer
Certificate was added to keystore
我有一个junit测试,用这些JVM选项调用远程服务器:
-ea -Djavax.net.debug=all -Dcom.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true
-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true
-Dcom.sun.xml.internal.ws.transport.http.HttpAdapter.dump=true
-Djavax.net.ssl.trustStore=certificate.cer
-Djavax.net.ssl.trustStoreType=PEM
-Djavax.net.ssl.trustStorePassword=pwd
-Djavax.net.ssl.keyStore=certificate.cer
-Djavax.net.ssl.keyStoreType=PEM
-Djavax.net.ssl.keyStorePassword=pwd
远程调用使用:
完成authenticationService.getAuthenticationServiceSoap().authenticateWithPasswordAuth(clientId, username, password);
我正在使用的客户端有这些注释:
@WebServiceClient
public class AuthenticationService extends Service {
and
@WebEndpoint(name = "AuthenticationServiceSoap")
public AuthenticationServiceSoap getAuthenticationServiceSoap()
我没有做任何代码明智的事情,我得到以下例外: 我甚至不理解java是否尝试使用https或不使用。
--- [HTTP请求 - http://..../Soap/AuthenticationService.asmx]---接受:[text / xml,multipart / related] Content-Type:[text / xml; charset = utf-8] SOAPAction: [“http://....../AuthenticateWithPasswordAuth”] User-Agent:[JAX-WS RI 2.2.4-B01]
引起:java.net.ConnectException:拒绝连接 java.net.PlainSocketImpl.socketConnect(Native Method)at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) 在 java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) 在 java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) 在java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)at java.net.Socket.connect(Socket.java:579)at java.net.Socket.connect(Socket.java:528)at sun.net.NetworkClient.doConnect(NetworkClient.java:180)at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)at sun.net.www.http.HttpClient。(HttpClient.java:211)at sun.net.www.http.HttpClient.New(HttpClient.java:308)at sun.net.www.http.HttpClient.New(HttpClient.java:326)at at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:997) 在 sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:976) 在 sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:851) 在 sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1092) 在 com.sun.xml.internal.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:105)