我正在尝试通过HTTPS发布SOAP Web服务。我可以使一切正常运行,但是无法在浏览器中访问该服务。
下面提供的是我与终端一起发布的SSL和服务器设置。我确保来自KeyStore的证书位于我的浏览器和计算机的信任库中。
SOAP服务
@WebService(name = "TestService")
@SOAPBinding
public interface TestService {
@WebMethod
void test();
}
服务实施
@MTOM
@WebService(
targetNamespace = "https://localhost",
endpointInterface = "bootstrap.TestService",
portName = "TestPort",
serviceName = "TestService"
)
public class TestServiceImpl implements TestService {
@Override
public void test() {
System.out.println("Hello");
}
}
SSL设置
SSLContext sslContext = SSLContext.getInstance("SSL");
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType());
store.load(EndpointPublisher.class.getResourceAsStream("KeyStore.ks"), "password".toCharArray());
System.setProperty("javax.net.ssl.keyStore", "/bootstrap/dev/KeyStore.ks");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
keyManagerFactory.init(store, "password".toCharArray());
trustManagerFactory.init(store);
KeyManager[] keyManagers = keyManagerFactory.getKeyManagers();
TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
sslContext.init(keyManagers, trustManagers, new SecureRandom());
服务器设置
String host = "localhost";
int port = 8080;
String uri = "/test";
TestService service = new TestServiceImpl();
HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress(host, port), port);
httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext));
HttpContext context = httpsServer.createContext(uri);
httpsServer.start();
Endpoint endpoint = Endpoint.create(service);
endpoint.publish(context);
我希望在连接到
时看到wsdlhttps://localhost:8080/test?wsdl
但是我知道
无法访问此网站
localhost意外关闭了连接。
尝试:
Checking the connection
Checking the proxy and the firewall
Running Windows Network Diagnostics
ERR_CONNECTION_CLOSED