Groovy httpbuilder を使用して Microsoft Exchange Web サービス (EWS) に投稿しようとしています。私の問題は、適切なリクエストのコンテンツ タイプを設定できないことです。図書館はここで独自の考えを持っているようです。
誰にもアイデアはありますか?
乾杯、ステファン
これが私のコードです:
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
}
}