Atozed Forums
CustomContentHandlers - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: CustomContentHandlers (/thread-926.html)



CustomContentHandlers - amit.walters - 01-26-2019

IntraWeb Version: 15.0.17

I have downloaded demo from https://github.com/Atozed/IntraWeb.
I need C++ code for the  delphi demo CustomContentHandlers.  In my project I need to send xml data to client depending on the parameter they have provided and CustomContentHandlers demo is doing exactly what I want but it is in delphi and I am unable to convert it to C++ code.

I tried but not working it says (404 file not found)
code writen by me
in ServerController.cpp
void __fastcall TIWServerController::IWServerControllerBaseConfig(TObject *Sender)

{
  THandlers::Add("", " GiveMeSomeXML", new  TContentXML());
}

in IW.Content.XML.cpp
 __fastcall  TContentXML :: TContentXML ()
{
}

__fastcall  TContentXML ::~ TContentXML ()
{
}

bool __fastcall  TContentXML ::Execute(Iw::Http::Request::THttpRequest* aRequest, Iw::Http::Reply::THttpReply* aReply, const System::UnicodeString aPathname,
                                          Iwapplication::TIWApplication* aSession, System::Classes::TStrings* aParams)
{
 aReply->ContentType = "text/xml";;
 aReply->WriteString("<xml>My xml content here</xml>");
}

in IW.Content.XML.h

class TContentXML : public Iw::Content::Base::TContentBase
{
private:    // User declarations

public:        // User declarations
   __fastcall virtual  TContentXML ();
   __fastcall  ~ TContentXML (void);

   virtual bool __fastcall Execute(Iw::Http::Request::THttpRequest* aRequest, Iw::Http::Reply::THttpReply* aReply, const System::UnicodeString aPathname, Iwapplication::TIWApplication* aSession, System::Classes::TStrings* aParams);

};

I know I have not converted it properly please help me


RE: CustomContentHandlers - amit.walters - 01-27-2019

it is solved.
I missed to add "mFileMustExist = false;"
thats way it was giving error file not found 404 error

__fastcall TContentXML::TContentXML()
{
mFileMustExist = false;
}