【问题标题】:play.libs.WS.WSRequestHolder.get() cuts off parts of request?play.libs.WS.WSRequestHolder.get() 切断部分请求?
【发布时间】:2014-01-12 00:19:06
【问题描述】:

我的程序应该调用 `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),它是正确的。

【问题讨论】:

    标签: java web-services playframework get playframework-2.2


    【解决方案1】:

    ? 之后的部分被视为“查询参数”,需要单独指定为WSRequestHolder 的构建器模式的一部分。因此,使用WS.WSRequestHolder API 中的setQueryParameter(String name, String value) 方法:

    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("");                  
    });
    

    【讨论】:

      猜你喜欢
      • 2017-08-14
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多