gpt4 book ai didi

java - 网络服务错误 : 404 Not found - No context found for request

转载 作者:行者123 更新时间:2023-11-30 09:09:58 26 4
gpt4 key购买 nike

我使用下面的代码来发布 ssl 网络服务。当我浏览 https://localhost/ 它给我这个错误:

404 Not Found

No context found for request

代码:

Endpoint endpoint = Endpoint.create(new TicketQueryImpl());
javax.net.ssl.SSLContext ssl = javax.net.ssl.SSLContext.getInstance("TLS");
javax.net.ssl.KeyManagerFactory keyFactory = javax.net.ssl.KeyManagerFactory
.getInstance(javax.net.ssl.KeyManagerFactory.getDefaultAlgorithm());
KeyStore store = KeyStore.getInstance("JKS");

store.load(new FileInputStream("c:/thekey.txt"), "password".toCharArray());
keyFactory.init(store, "password".toCharArray());

TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory
.getDefaultAlgorithm());
trustFactory.init(store);
ssl.init(keyFactory.getKeyManagers(), trustFactory.getTrustManagers(), new SecureRandom());
HttpsConfigurator configurator = new HttpsConfigurator(ssl);
HttpsServer httpsServer = HttpsServer.create(new InetSocketAddress("localhost", 443), 443);
httpsServer.setHttpsConfigurator(configurator);
HttpContext httpContext = httpsServer.createContext("/127.0.0.1:443/");
httpsServer.start();

endpoint.publish(httpContext);

我该如何解决这个问题,为什么会出现这个问题?

最佳答案

我是多么愚蠢。 https.createContext(uri) 中的 URI 不是整个路径的 URI。我变了

HttpContext httpContext = httpsServer.createContext("/127.0.0.1:443/");

HttpContext httpContext = httpsServer.createContext("/test");

然后浏览https://127.0.0.1/test?wsdl有效。

关于java - 网络服务错误 : 404 Not found - No context found for request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22740860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com