1

私はgroovyに次のコードを持っています

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

        }
    }

xmlRssを返します。問題が何であるかわかりません。グルーヴィーなコードではすべて問題ないように見えます。また、Httpリターンコードは200です。

4

1 に答える 1

3

Javaで記述したコードは、Groovyの次のコードと同等です。

def oracle = "https://ronna-afghan.harmonieweb.org/_layouts/srchrss.aspx?k=execution&count=1&format=rss".toURL().text
于 2012-02-20T02:30:34.793 に答える