0

您好,我想知道如何发布 urlencoded 字符串并使用 HTTPBuilder 读取 xml 响应?我想在 Grails 应用程序中使用它。REST 插件是没有选择的。我尝试了http://groovy.codehaus.org/modules/http-builder/doc/post.html上给出的示例,但这没有给我读入的 xml 响应。

4

1 回答 1

1

你可以尝试这样的事情:

def httpBuilder = new HTTPBuilder("http://webite.url")

httpBuilder.request(Method.POST, URLENC){req->
    headers.accept = "application/xml"
    body = [ YOUR URL ENCODED POST]

    response.success = {resp,xml->
       //read xml response.
    }
}
于 2012-01-04T14:06:49.413 回答