问题描述
我想接近Exchange EWS webservice并自己处理XML SOAP组合(请求)和解析(响应)。
因此,THTPPRIO似乎有点过分。
I want to approach the Exchange EWS webservice and handle XML SOAP composition (request) and parsing (response) myself.Therefore, THTPPRIO seems a bit overkill.
我正在尝试THTTPReqResp,但我被困在这里:
I'm trying THTTPReqResp, but I'm stuck here:
Web服务不符合规范,并且希望
The web service does not follow the specs and expects a
Content-Type: text/xml; charset=utf-8
而不是
Content-Type: text/xml; charset="utf-8"
如何使用THTTPReqResp添加/覆盖标题?
以下是迄今为止的代码:
How can I add/overwrite a header using THTTPReqResp?Here's the code so far:
HTTPReqResp1.SoapAction := '"http://schemas.microsoft.com/exchange/services/2006/messages/ResolveNames"';
// HTTPReqResp1.UseUTF8InHeader := true; // Already
HTTPReqResp1.URL := 'https://webmail.mailserver.nl/ews/exchange.asmx';
HTTPReqResp1.Execute(TSRequest,TSResponse);
内容类型错误发生在执行(或在接收,如果我使用发送/接收代替的执行)
The Content-Type error occurs on the Execute (or on the Receive if I use Send/Recieve instead of Execute)
BTW如果THTTPReqResp不正确的方式,欢迎评论。我也在尝试TidHTTP,请参阅。
BTW If THTTPReqResp is not the right way to, comments are welcome. I'm also trying TidHTTP, see this post.
Delphi XE2 Update 4 with Indy 10.5.8.0
Delphi XE2 Update 4 with Indy 10.5.8.0
感谢
Jan
ThanksJan
推荐答案
我发现它:
procedure TForm1.BeforeRRPost(const HTTPReqResp: THTTPReqResp; Data: Pointer);
const
cContentHeader = 'Content-Type: text/xml; charset=utf-8';
begin
HttpAddRequestHeaders(Data, PChar(cContentHeader), Length(cContentHeader), HTTP_ADDREQ_FLAG_REPLACE);
// Or HttpAddRequestHeaders(Data, PChar(cContentHeader), Length(cContentHeader), HTTP_ADDREQ_FLAG_ADD);
end;
然后在HTTPReqResp1.Execute或HTTPReqResp1.Send:
and then before the HTTPReqResp1.Execute or HTTPReqResp1.Send:
HTTPReqResp1.OnBeforePost := BeforeRRPost;
这篇关于如何使用THTTPReqResp添加/覆盖HTTP标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!