sto provando a creare un'applicazione Rest in DataSnap in esecuzione come servizio Windows, ma la procedura guidata ha solo "Applicazione VCL standalone", "Applicazione console standalone" e "Libreria di collegamento dinamico ISAPI" "(sto usando l'azienda Delphi XE2). Qualcuno può aiutarmi. Grazie.DataSnap Rest Server windows Service
6
A
risposta
4
Sarebbe più comodo se la procedura guidata REST di DataSnap avesse la possibilità di creare un servizio di Windows (in quale altro modo si potrebbe eseguire un server delle applicazioni?), Ma si può aggirare il problema con un po 'di giocherellando.
La prima volta che mi sono imbattuto in questo, ho creato un server REST DataSnap regolare come un'applicazione VCL e un normale servizio Windows e ho copiato le parti rilevanti dal server REST al servizio. Assicurati che la directory di output per il servizio sia la stessa della directory per l'applicazione VCL. .dpr
del servizio potrebbe assomigliare a questo: unità principale
program Service;
uses
Vcl.SvcMgr,
Web.WebReq,
IdHTTPWebBrokerBridge,
WebModuleUnit1 in '..\GUI\WebModuleUnit1.pas' {WebModule1: TWebModule},
ServerMethodsUnit1 in '..\GUI\ServerMethodsUnit1.pas' {ServerMethods1: TDSServerModule},
ServerContainerUnit1 in '..\GUI\ServerContainerUnit1.pas' {ServerContainer1: TDataModule},
Unit1 in 'Unit1.pas' {Service1: TService};
{$R *.RES}
begin
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
Application.CreateForm(TService1, Service1);
Application.Run;
end.
del servizio potrebbe assomigliare a questo:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,
IdHTTPWebBrokerBridge, Web.HTTPApp;
type
TService1 = class(TService)
procedure ServiceCreate(Sender: TObject);
procedure ServiceExecute(Sender: TService);
procedure ServiceStart(Sender: TService; var Started: Boolean);
procedure ServiceStop(Sender: TService; var Stopped: Boolean);
private
FServer: TIdHTTPWebBrokerBridge;
procedure TerminateThreads;
public
function GetServiceController: TServiceController; override;
end;
var
Service1: TService1;
implementation
{$R *.DFM}
uses
//Datasnap.DSService; // XE2
Datasnap.DSSession; // XE3
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Service1.Controller(CtrlCode);
end;
{ TService1}
function TService1.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TService1.ServiceCreate(Sender: TObject);
begin
FServer := TIdHTTPWebBrokerBridge.Create(Self);
end;
procedure TService1.ServiceExecute(Sender: TService);
begin
while not Terminated do
begin
Sleep(1000);
ServiceThread.ProcessRequests(False);
end;
end;
procedure TService1.ServiceStart(Sender: TService; var Started: Boolean);
begin
if not FServer.Active then
begin
FServer.Bindings.Clear;
FServer.DefaultPort := 8080;
FServer.Active := True;
end;
end;
procedure TService1.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
TerminateThreads;
FServer.Active := False;
FServer.Bindings.Clear;
ServiceThread.Terminate;
end;
procedure TService1.TerminateThreads;
begin
if TDSSessionManager.Instance <> nil then
TDSSessionManager.Instance.TerminateAllSessions;
end;
end.
Problemi correlati
- 1. Come mappare i prefissi dei metodi HTTP personalizzati su un server DESThi DataSnap REST
- 2. C'è un modo per usare JSONP con un server REST Delphi DataSnap?
- 3. windows service - config file
- 4. py2exe windows service problem
- 5. Service Bus 2.1 per Windows Server - TimeOutException sul metodo EndReceive
- 6. REST server in Delphi XE2 pro
- 7. Datasnap and SocketError
- 8. WCF REST e SOAP Service senza WebServiceHostFactory
- 9. Consuming Rest Service the functional way
- 10. Rest Web service che restituisce un 404
- 11. WCF Rest Service - Accesso all'intestazione HTTP Reponse
- 12. Windows Service vs Windows Application - Best Practice
- 13. Windows Service Problema di installazione
- 14. Come connettersi a SQL Server con l'autenticazione di Windows da Windows-Service?
- 15. Delphi XE7 DataSnap con puro JSON
- 16. Passaggio da EXE autonomo a Windows Service
- 17. Dominio incrociato jQuery Richiesta Ajax e WCF REST Service
- 18. Haskell come server REST
- 19. Multiple SessionFactories in Windows Service con NHibernate
- 20. Network Service Discovery su Windows Phone
- 21. eccezione non gestita in Windows Service
- 22. GUI di Windows Service Plus/C#
- 23. Scaling SignalR con Windows Azure Service Bus
- 24. HTTP Put Enum utilizzando JAX-RS REST-Service
- 25. Come utilizzare dojo/store/JsonRest per funzionare ArcGIS Rest Service
- 26. Rest Web Service con App Engine e Webapp
- 27. Jersey REST Web Service, Tomcat, Eclipse e 404's
- 28. Delphi 2010 Datasnap - Query di progettazione
- 29. API .NET per SQL Server Service Broker
- 30. Accesso Drupal tramite server Rest
Perché gli stretti richieste? In che modo questa domanda non è costruttiva? –