0
嗨,我想知道如何我可以發佈一個urlencoded字符串,並在使用HTTPBuilder的XML響應中讀取?我想在Grails應用程序中使用它。 REST插件是沒有選擇的。我試着http://groovy.codehaus.org/modules/http-builder/doc/post.html給出的例子,但是這給了我沒有XML響應在讀HTTPBuilder HTTP發佈url編碼參數並接受xml響應?
嗨,我想知道如何我可以發佈一個urlencoded字符串,並在使用HTTPBuilder的XML響應中讀取?我想在Grails應用程序中使用它。 REST插件是沒有選擇的。我試着http://groovy.codehaus.org/modules/http-builder/doc/post.html給出的例子,但是這給了我沒有XML響應在讀HTTPBuilder HTTP發佈url編碼參數並接受xml響應?
你可以嘗試這樣的事情:
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.
}
}
TXS ..它確實是這麼簡單..! – Marco 2012-01-19 10:06:16