首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是mORMot网络服务的真实web-url?

什么是mORMot网络服务的真实web-url?
EN

Stack Overflow用户
提问于 2015-09-11 18:27:59
回答 1查看 1.3K关注 0票数 1

请帮助了解有关的路由和网站网址以下网站服务。

代码语言:javascript
复制
type
  TAirportService = class(TInterfacedObject, IAirportService)
  public
    procedure GetAirportDefinition(const AirPortID: integer; out Definition: TDTOAirportDefinition);
  end;

procedure TAirportService.GetAirportDefinition(const AirPortID: integer;
  out Definition: TDTOAirportDefinition);
begin
  // create an object from static data
  // (real application may use database and complex code to retrieve the values)
  with Definition.Airport.Add do begin
    Location := 'LAX';
    Terminal := TRawUTF8DynArrayFrom(['terminalA', 'terminalB', 'terminalC']);
    Gate := TRawUTF8DynArrayFrom(['gate1', 'gate2', 'gate3', 'gate4', 'gate5']);
    BHS := 'Siemens';
    DCS := 'Altiea';
  end;
  with Definition.Airline.Add do begin
    CX := TRawUTF8DynArrayFrom(['B777', 'B737', 'A380', 'A320']);
    QR := TRawUTF8DynArrayFrom(['A319', 'A380', 'B787']);
    ET := '380';
    SQ := 'A320';
  end;
  Definition.GroundHandler := TRawUTF8DynArrayFrom(['Swissport','SATS','Wings','TollData']);
end;

procedure StartWebService();
var
  aModel: TSQLModel;
  aDB: TSQLRestServer;
  aServer: TSQLHttpServer;
begin
  // set the logs level to only important events (reduce .log size)
  TSQLLog.Family.Level := LOG_STACKTRACE+[sllInfo,sllServer];
  // initialize the ORM data model
  aModel := TSQLModel.Create([]);
  try
    // create a fast in-memory ORM server
    aDB := TSQLRestServerFullMemory.Create(aModel,'test.json',false,false);
    try
      // register our TAirportServer implementation
//      aDB.ServiceRegister(TServiceCalculator,[TypeInfo(ICalculatorXML)],sicShared);
      aDB.ServiceRegister(TAirportService,[TypeInfo(IAirportService)],sicShared);
      // launch the HTTP server
      aServer := TSQLHttpServer.Create('8092', [aDB], '+', useHttpApiRegisteringURI);
      try
        aServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
        writeln('Background server is running'#10);
        write('Press [Enter] to close the server.');
        ConsoleWaitForEnterKey;
      finally
        aServer.Free;
      end;
    finally
      aDB.Free;
    end;
  finally
    aModel.Free;
  end;
end;

我试着给追踪网址打电话:

  • http://localhost:8092/root/AirportService/GetAirportDefinition?AirPortID=1
  • http://localhost:8092/root/AirportService.GetAirportDefinition?AirPortID=1
  • http://localhost:8092/root/AirportService/GetAirportDefinition
  • http://localhost:8092/AirportService/GetAirportDefinition?AirPortID=1
  • http://localhost:8092/AirportService.GetAirportDefinition?AirPortID=1
  • http://localhost:8092/AirportService/GetAirportDefinition

但每次我得到:

{ "errorCode":400, "errorText":"Bad Request" }

Bad request

我哪里错了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-14 07:22:50

A是错误的,下面的urls确实是按需要工作的:

  • http://localhost:8092/root/AirportService/GetAirportDefinition?AirPortID=1
  • http://localhost:8092/root/AirportService.GetAirportDefinition?AirPortID=1
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32529937

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档