문제

Hi there i am wondering how i can post a urlencoded string and read in an xml response using HTTPBuilder? I would like to use this inside a Grails application. The REST plugin is no option. I tried the examples given on http://groovy.codehaus.org/modules/http-builder/doc/post.html but this gives me no xml response to read in.

도움이 되었습니까?

해결책

You can try something like this:

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.
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top