Jump to content


Photo

combining UniGui with REST-WebService


  • Please log in to reply
8 replies to this topic

#1 bitschieber

bitschieber

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationGermany

Posted 06 March 2014 - 02:58 PM

Hi all!

We are trying to combine the TUniServerModule with our
REST-WebService-component (customized Indy HttpServer).

In this case, is there any posibility to get an event like Indy's
Http-Server 'OnCommandGet' or 'OnCommandOther' to handle individual
http-reqeusts? We want to use only one port in the whole application to
avoid cross-domain problems.

Thanks a lot

 


  • 1

#2 Farshad Mohajeri

Farshad Mohajeri

    Administrator

  • Administrators
  • 9980 posts

Posted 06 March 2014 - 03:29 PM

Moved to Feature Requests.


  • 1

#3 Farshad Mohajeri

Farshad Mohajeri

    Administrator

  • Administrators
  • 9980 posts

Posted 06 March 2014 - 03:29 PM

Can you specify more details?


  • 1

#4 bitschieber

bitschieber

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationGermany

Posted 07 March 2014 - 06:54 AM

We are currently using self-programmed components which communicate via web services rest. We want to include these components in our Unigui application. That is why we need a service of Unigui and REST Web services can operate. 
A proposed solution would be to declare public 
  'OnCommandGet' and 'OnCommandOther'.

  • 1

#5 bitschieber

bitschieber

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationGermany

Posted 10 March 2014 - 06:17 PM

Thanks for the quick adjustment, 
it works as desired. 
 
Great future: 0001343: Server event to handle all HTTP calls. 
 
Thank you

  • 0

#6 bitschieber

bitschieber

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationGermany

Posted 14 March 2014 - 10:13 AM

Hi!
 
Thanks a lot for implementing the new OnHttpCommand-Event, it was really helpful!
 
But we noticed that not all common http-methods are supported in this event, for example DELETE, PUT or OPTIONS. Only GET and POST are still working. To implement an entire REST-ful webservice, we do need the methods: GET, PUT, POST, DELETE and OPTIONS.
 
Is there any way to get the "OnHttpCommand"-event triggered on those HTTP-standarded methods?
 
Thanks a lot!

  • 0

#7 Farshad Mohajeri

Farshad Mohajeri

    Administrator

  • Administrators
  • 9980 posts

Posted 15 March 2014 - 04:31 AM

It will be fixed in next version..

 

Workaround:

unit ServerModule;
interface
uses
  SysUtils, uniGUIServer, uniGUIMainModule, uniGUIApplication,  

// add
  uIdContext,
  uIdCustomHTTPServer,
  ExtHTTPServer;
// add

type
  TUniServerModule = class(TUniGUIServerModule)
    procedure UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo;
      AResponseInfo: TIdHTTPResponseInfo; var Handled: Boolean);
  private
    { Private declarations }
  protected
    procedure FirstInit; override;
  public
    { Public declarations }  
// add
    procedure CommandOther(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
    procedure AfterConstruction; override;
// add
  end;

function UniServerModule: TUniServerModule;

implementation

{$R *.dfm}
uses
  UniGUIVars;

function UniServerModule: TUniServerModule;
begin
  Result:=TUniServerModule(UniGUIServerInstance);
end;

procedure TUniServerModule.FirstInit;
begin
  InitServerModule(Self);
end;

// add
procedure TUniServerModule.AfterConstruction;
begin
  inherited;
  ExtApplication.Server.OnCommandOther := CommandOther;
end;

procedure TUniServerModule.CommandOther(AContext: TIdContext; ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
//
end;
// add

procedure TUniServerModule.UniGUIServerModuleHTTPCommand(ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo;  var Handled: Boolean);
begin
//
end;

initialization
  RegisterServerModuleClass(TUniServerModule);
end.

  • 0

#8 bitschieber

bitschieber

    Newbie

  • Members
  • Pip
  • 9 posts
  • LocationGermany

Posted 15 March 2014 - 01:25 PM

Thanks for the quick help.


  • 0

#9 shawdown

shawdown

    Member

  • uniGUI Subscriber
  • PipPip
  • 33 posts

Posted 16 January 2018 - 07:56 PM

Any way for this to work with isapi?


  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users