1
我有下面的代碼常規常規HTTP生成器沒有返回結果
HTTPBuilder http = new HTTPBuilder("https://ronna-afghan.harmonieweb.org/_layouts/searchrss.aspx")
http.request(Method.GET, groovyx.net.http.ContentType.XML) {
// set username and password for basic authentication
// set username and password for basic auth
//http.auth.basic(ConfigurationHolder.config.passportService.userName,
// ConfigurationHolder.config.passportService.password)
headers.'User-Agent' = 'Mozilla/5.0'
uri.query = [k:'execution']
// response handler for a success response code:
response.success = {resp, xml ->
println resp.statusLine
log.debug "response status: ${resp.statusLine}"
log.debug xml.toString()
}
// handler for any failure status code:
response.failure = {resp ->
log.error " ${resp.statusLine.statusCode} : ${resp.statusLine.reasonPhrase}"
}
}
當我運行的代碼,它並沒有給我的RSS訂閱我敢猜想得到
當我在java中有相同的代碼
try {
// Create a URLConnection object for a URL
URL oracle = new URL(
"https://ronna-afghan.harmonieweb.org/_layouts/srchrss.aspx?k=execution&count=1&format=rss");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
in.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
它返回xml Rss。我無法確定問題可能是什麼。一切看起來都還好我在Groovy代碼,也是HTTP返回代碼爲200
有道理。它的工作現在。我有從配置文件中讀取的URL,它有一個錯字。由此獲得失敗。這兩個代碼都返回正確的結果。 – allthenutsandbolts 2012-02-21 18:16:52
您是否可以說提供的答案是給出問題細節問題的可接受答案? :) – 2012-02-21 19:41:48
是的,我已經標記了它 – allthenutsandbolts 2012-02-21 19:52:18