0
它總是捕捉異常,並輸出到檢索XML文件時「無法讀取數據$ DID:$別名」當我運行閱讀():HttpResponseException嘗試使用Groovy腳本
http = new HTTPBuilder('https://somewebsite.com')
def read(http, path, dId, alias, portalFile, outputFileName) {
try {
println "Reading : path:$path, file:$portalFile"
http.get(path: path,
contentType: TEXT,
query: [id:dId, instance:alias, format:'xml', file:portalFile]) {resp, reader ->
println "response status: ${resp.statusLine}"
println 'Headers: -----------'
resp.headers.each { h ->
println " ${h.name} : ${h.value}"
}
new File(outputFileName).withWriter{out -> out << reader}
}
} catch (HttpResponseException h) {
println "Unable to read data for $dId:$alias"
}
}
如果我去該網站使用我的互聯網瀏覽器,並點擊我需要的XML文件,它的工作原理。有什麼方法可以輸出它連接的URL嗎?