我的程序应该调用`https://somepath.com/terminallocation/?msisdn=number“,但是似乎?之后的所有内容都被切断了。我花了最后3个小时在此上,尝试次数有限,如果有人可以帮助,那就太好了。
public static play.libs.F.Promise<Result> locationControllerGET(
String number) {
String feedUrl = "https://somepath.com/terminallocation/?msisdn="
+ number;
Logger.debug(WS.url(feedUrl)
.setAuth("user", "password", com.ning.http.client.Realm.AuthScheme.BASIC).getUrl().toString());
final play.libs.F.Promise<Result> resultPromise = WS.url(feedUrl)
.setAuth("48509237274", "Y7A7HNM3EFF3LF", com.ning.http.client.Realm.AuthScheme.BASIC).get()
.map(new Function<WS.Response, Result>() {
return ok("");
});
return resultPromise;
}
记录器的控制台输出:
[debug] application - https://somepath.com/terminallocation/?msisdn=number
我还检查了
Logger.debug.debuf(deedUrl)
,它是正确的。 最佳答案
?
之后的部分被视为“查询参数”,需要作为WSRequestHolder
生成器模式的一部分单独指定。因此,使用setQueryParameter(String name, String value)
API中的WS.WSRequestHolder
方法:
String feedUrl = "https://somepath.com/terminallocation/";
final play.libs.F.Promise<Result> resultPromise = WS.url(feedUrl)
.setQueryParameter("msisdn", number)
.setAuth("48509237274", "Y7A7HNM3EFF3LF", com.ning.http.client.Realm.AuthScheme.BASIC).get()
.map(new Function<WS.Response, Result>() {
return ok("");
});