Java 空响应,当我应该获取xml时
当我键入某个URL时,我会得到xml文件Java 空响应,当我应该获取xml时,java,xml,playframework,playframework-2.0,Java,Xml,Playframework,Playframework 2.0,当我键入某个URL时,我会得到xml文件 <response> <result>something</result> <description>description</description> </response> 它输出OK[#文档:null] 我想我对这段代码的作用有一些基本的误解,我认为它会转到feedUrl,在要求验证时从setAuth传递参数,并映射服务器在结果中返回的内容。我错了吗?如果是,我该
<response>
<result>something</result>
<description>description</description>
</response>
它输出OK[#文档:null]
我想我对这段代码的作用有一些基本的误解,我认为它会转到feedUrl,在要求验证时从setAuth传递参数,并映射服务器在结果中返回的内容。我错了吗?如果是,我该怎么做
编辑:如果想获得地址指向的网站内容,应该使用return
ok(response.getStatusText()+“”+response.getBody.toString())
如果想要获得地址指向的网站内容,应该做的是使用返回ok(response.getStatusText()+“”+response.getBody.toString())代码>如果您的编辑是解决方案,您应该将其作为答案发布在下面,而不是问题中。
public static play.libs.F.Promise<Result> locationControllerGET(String number) {
String feedUrl = "https://somepath/?msisdn="+number;
final play.libs.F.Promise<Result> resultPromise = WS.url(feedUrl).setAuth("user", "password").get().map(
new Function<WS.Response, Result>() {
public Result apply(WS.Response response) {
return ok(response.getStatusText()+" "+response.asXml());
}
}
);
return resultPromise;
}