[英]Delphi - SOAP Request issue with HTTPRIO component
所有
我正面臨來自delphi的SOAP請求的奇怪問題,它正在工作,但未給出預期的結果。因此,我開始使用SOAP UI進行調試,發現以下發現。
當使用SOAP UI工具時,我嘗試創建新請求並使用下面的標頭創建它,但是它沒有按預期工作(從delphi發送請求時面臨着同樣的問題)。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
但是,如果我在SOAP UI請求中將標頭更改為以下標題,則會得到預期的結果。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:acc="http://schemas.datacontract.org/2004/07/AccountService.DataContracts" xmlns:acc1="http://schemas.datacontract.org/2004/07/AccountService.FaultContracts">
如何在Delphi 2010中將標頭更改為HTTPRIO對象?
一種可能性是在THTTPRIO
對象的OnBeforeExecute
事件處理程序中修改request
。
如下所示:
procedure TForm1.RIOBeforeExecute(const MethodName: string; SOAPRequest: TStream);
var
sl : TStringList;
begin
SOAPRequest.Position := 0;
sl := TStringList.Create;
try
sl.LoadFromStream(SOAPRequest);
sl.Text := StringReplace(sl.Text, 'old header text', 'new header text', [rfReplaceAll]);
SOAPRequest.Size := 0;
SOAPRequest.Position := 0;
sl.SaveToStream(SOAPRequest);
finally
sl.Free;
end;
end;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.