I have some legacy Delphi code that POSTs XML to a secure web server using the MSXML component.
The code has been working fine for years. Recently, we made some changes that makes the XML file size a bit larger, but not by much. The XML size itself is still relatively small, eg, 100k or less.
We checked the server logs and the failure is an authentication error due to the fact that user/pass are sometimes not passed. This happens intermittently. The only thing that has changed is that the XML size has grown a bit.
I can verify this by incrementally growing an xml file until the POST fails. I can also verify by doing the reverse, (ie, taking a large file and incrementally reducing it until it POSTs successfully).
Here is some sample code below. In this case I load the xml from file. In the actual code we use streams, but I am certain this is not the issue.
Does anyone know why the authentication data would get lost on the way to the https server? I seem to recall something about MSXML having problems with negotiating authentication in certain cases, but I don't think it had to do with the size of the XML being Posted.
procedure TForm1.IntermittentFail;
Var
Resp : TStringStream ;
ole : OleVariant;
HTTPParams: TStrings;
aStream : TStream;
FXMLDoc : TXMLDocument ;
FXMLResp : TXMLDocument;
user, pass, URL, CommonStr : string;
begin
if not(odXMLFile.Execute) then
exit;
user := 'JoeUser';
pass := 'password
URL := 'https://aURL.com';
CommonStr := 'ParameterString';
FXMLDoc := TXMLDocument.Create(Nil);// create the outgoing doc
FXMLResp := TXMLDocument.Create(Nil);// create the response doc
Resp := nil;
FXMLDoc.LoadFromFile(odXMLFile.FileName);
ole := CreateOleObject('MSXML2.ServerXmlHttp');
ole.open('POST' ,URL , false, user, pass);
ole.SetTimeouts( 0, 60000, 300000, 300000);
//ole.SetTimeouts( 300000, 300000, 300000, 300000); //no effect.
ole.setOption(3, CommonStr);
//ole.setrequestheader('connection', 'close'); //no effect //sleep(5000); //no effect
ole.Send(FXMLDoc.XML.Text); //THIS WILL INTERMITTENTLY FAIL.
Resp := TStringStream.Create(ole.ResponseText);
finally
ole := Unassigned;
if Assigned(Resp) then
Resp.Free;
FXMLDoc.Free;
FXMLResp.Free;
end;
end;
Thank you -