我试图在开发模式下在HTTPs上运行play framework 2.2.1应用程序.我使用以下命令:
Development/Play/ssltest$ JAVA_OPTS=-Dhttps.port=9443 play run
Run Code Online (Sandbox Code Playgroud)
我得到了以下,这似乎没问题
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
[info] play - Listening for HTTPS on port /0:0:0:0:0:0:0:0:9443
(Server started, use Ctrl+D to stop and go back to the console...)
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试通过HTTPS连接到应用程序时:
"https://localhost:9443"
Run Code Online (Sandbox Code Playgroud)
应用程序崩溃,我进入以下一堆例外:
[error] play - Error loading fake key store
java.security.cert.CertificateException: Subject class type invalid.
at sun.security.x509.X509CertInfo.setSubject(X509CertInfo.java:888) ~[na:1.8.0-ea]
at sun.security.x509.X509CertInfo.set(X509CertInfo.java:415) ~[na:1.8.0-ea]
at play.core.server.netty.FakeKeyStore$.createSelfSignedCertificate(FakeKeyStore.scala:71) ~[play_2.10.jar:2.2.1]
at play.core.server.netty.FakeKeyStore$.keyManagerFactory(FakeKeyStore.scala:34) ~[play_2.10.jar:2.2.1]
at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:98) [play_2.10.jar:2.2.1]
at play.core.server.NettyServer$PlayPipelineFactory$$anonfun$sslContext$2.apply(NettyServer.scala:94) …Run Code Online (Sandbox Code Playgroud) 我有一个控制器动作,我需要调用第三方Web服务.
我的问题是我没有打电话给一个网络服务.我需要链接4到5个Web服务.我调用的每个Web服务都返回一个我需要处理的JSON对象,并根据一些逻辑决定调用另一个Web服务(来自4个Web服务)或者向调用者返回响应.这是我想要做的:
public static Promise<Result> accounts(){
return WS.url("url1").get().map(response1 -> {
JsonNode mynode = response1.asJson();
if (mynode.get("status").asInt()==200){
Promise<JsonNode> jsonPromise = WS.url("url2").get().map(response2->{
return response2.asJson();
});
}
return ok(mynode);
});
}
Run Code Online (Sandbox Code Playgroud)
现在,从文档中,我认为我需要的是链接每个Web服务调用是承诺的承诺.但我不知道该怎么做?
谢谢