作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用下面的代码来发布 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/
我是一名优秀的程序员,十分优秀!