Mark Williams 14 Posted November 16, 2019 I'm using TWebModule in an ISAPI DLL. I am using it to return data from a database in xml format using IXMLDocument. Last night I had a problem with text data which included characters such as "/". I assume the returned text was being formatted somewhere along the line to insert escape characters with the result that the received xml at the other end is always slightly short so that you end up with a badly formed xml document. So, for example, if the returned text had two "/" characters the xml document when received is short the last two characters. My code on the server side is: Response.Content := doc.XML.Text; Response.ContentLength :=length(doc.XML.text); I also tried determining the ContentLength using "length(Response.Content)", but that made no difference. I edited the data in the database to remove the "/" characters and all worked fine. I have now tried to replicate the problem so that I can seek some advice as to possible causes, but the xml is no longer being truncated. I am puzzled and keen to avoid the issue for the future, but unable to provide any more info because I can't now replicate the problem. Does anyone have any ideas as to what may have caused the problem initially? Share this post Link to post
Attila Kovacs 629 Posted November 17, 2019 I have no clue, but you could watch this video, how to create a console application from the broker to be able to debug your code. Share this post Link to post
Mark Williams 14 Posted November 17, 2019 8 hours ago, Attila Kovacs said: I have no clue, but you could watch this video, how to create a console application from the broker to be able to debug your code. No video link? However, don't think it would help. There is no exception and in any event my code is wrapped in try...except statements with exceptions outputted to a log file. Also, as mentioned in my post I cannot now reproduce the problem and don't understand why it was happening in the first place. I am just keen to avoid a repeat. Share this post Link to post
Guest Posted November 17, 2019 Simple assignment to Content should be sufficient: Response.Content := doc.XML.Text; This will both encode the incoming string value and set ContentLength automatically. (See TISAPIResponse.SetContent in Web.Win.IsapiHTTP.) In your case the encoded stream was longer than the original text, e.g. due to insertion of escape characters. By setting ContentLength explicitly you have effectively truncated the encoded stream. Share this post Link to post
Mark Williams 14 Posted November 17, 2019 6 minutes ago, Ondrej Kelle said: Simple assignment to Content should be sufficient: Response.Content := doc.XML.Text; This will both encode the incoming string value and set ContentLength automatically. (See TISAPIResponse.SetContent in Web.Win.IsapiHTTP.) In your case the encoded stream was longer than the original text, e.g. due to insertion of escape characters. By setting ContentLength explicitly you have effectively truncated the encoded stream. That makes sense. Many thanks. Share this post Link to post
Attila Kovacs 629 Posted November 17, 2019 @Mark Williams LOL Sorry I must have been very tired. https://chapmanworld.com/2017/06/15/installing-webbroker-projects-in-microsoft-iis/ Share this post Link to post