2
groovy httpbuilder를 사용하여 Microsoft Exchange 웹 서비스 (EWS)에 게시하려고합니다. 내 문제는 적절한 요청 콘텐츠 유형을 설정할 수 없다는 것입니다. 도서관에는 여기에 자신의 마음이있는 것 같습니다.groovy에서 요청시 콘텐츠 유형을 지정하는 방법은 무엇입니까?
누구나 아이디어가 있습니까?
건배, 스테판 여기
내 코드입니다 :
글쎄, 읽기, 코드를 디버깅, 내 현재 해결 방법/솔루션이 발견url = "http://exchangeserver/ews/Exchange.asmx"
p_body = "<soap request >...";
p_contentType = "text/xml; charset=utf-8"
customHeaders = ["SOAPAction":"LONG_URL"]
def http = new HTTPBuilder(url);
http.auth.basic(authMap.username, authMap.password)
// contentType: p_contentType,
http.request(POST)
{
contentType = ContentType.TEXT // We dont want to get the response parsed
headers['Accept'] = "*/*"; // Just make sure we accept everything
// Support additional headers
for (x in customHeaders) {
headers[x] = customHeaders[x]
}
/// Exchange expects "text/xml; charset=utf-8" and nothing else :(
// This sends text/plain
// body = p_body
// requestContentType = p_contentType
// This sends application/xml, not my "text/xml; charset=utf-8" content-type.
send p_contentType, p_body
// a successfull request should be "logged" ;)
response.success = { resp, xml ->
println xml
}
}