⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iihello1.pas

📁 用Delphi实现Web Service的简单示例
💻 PAS
字号:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://localhost/Hello.dll/wsdl/IIHello
// Encoding : utf-8
// Version  : 1.0
// (2007-12-15 17:35:07 - 1.33.2.5)
// ************************************************************************ //

unit IIHello1;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

  // ************************************************************************ //
  // The following types, referred to in the WSDL document are not being represented
  // in this file. They are either aliases[@] of other types represented or were referred
  // to but never[!] declared in the document. The types from the latter category
  // typically map to predefined/known XML or Borland types; however, they could also 
  // indicate incorrect WSDL documents that failed to declare or import a schema type.
  // ************************************************************************ //
  // !:double          - "http://www.w3.org/2001/XMLSchema"
  // !:string          - "http://www.w3.org/2001/XMLSchema"

  TMyEmployee          = class;                 { "urn:IHelloIntf" }

  { "urn:IHelloIntf" }
  TEnumTest = (etNone, etAFew, etSome, etAlot);

  TDoubleArray = array of Double;               { "urn:IHelloIntf" }


  // ************************************************************************ //
  // Namespace : urn:IHelloIntf
  // ************************************************************************ //
  TMyEmployee = class(TRemotable)
  private
    FLastName: WideString;
    FFirstName: WideString;
    FSalary: Double;
  published
    property LastName: WideString read FLastName write FLastName;
    property FirstName: WideString read FFirstName write FFirstName;
    property Salary: Double read FSalary write FSalary;
  end;


  // ************************************************************************ //
  // Namespace : urn:IHelloIntf-IIHello
  // soapAction: urn:IHelloIntf-IIHello#%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : rpc
  // binding   : IIHellobinding
  // service   : IIHelloservice
  // port      : IIHelloPort
  // URL       : http://localhost/Hello.dll/soap/IIHello
  // ************************************************************************ //
  IIHello = interface(IInvokable)
  ['{B1DC45F8-74F6-56CA-455F-8C912CD0528C}']
    function  echoEnum(const Value: TEnumTest): TEnumTest; stdcall;
    function  echoDoubleArray(const Value: TDoubleArray): TDoubleArray; stdcall;
    function  echoMyEmployee(const Value: TMyEmployee): TMyEmployee; stdcall;
    function  echoDouble(const Value: Double): Double; stdcall;
    function  sayHello(const name: WideString): WideString; stdcall;
  end;

function GetIIHello(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IIHello;


implementation

function GetIIHello(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IIHello;
const
  defWSDL = 'http://localhost/Hello.dll/wsdl/IIHello';
  defURL  = 'http://localhost/Hello.dll/soap/IIHello';
  defSvc  = 'IIHelloservice';
  defPrt  = 'IIHelloPort';
var
  RIO: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as IIHello);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = nil) and (HTTPRIO = nil) then
      RIO.Free;
  end;
end;


initialization
  InvRegistry.RegisterInterface(TypeInfo(IIHello), 'urn:IHelloIntf-IIHello', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IIHello), 'urn:IHelloIntf-IIHello#%operationName%');
  RemClassRegistry.RegisterXSInfo(TypeInfo(TEnumTest), 'urn:IHelloIntf', 'TEnumTest');
  RemClassRegistry.RegisterXSInfo(TypeInfo(TDoubleArray), 'urn:IHelloIntf', 'TDoubleArray');
  RemClassRegistry.RegisterXSClass(TMyEmployee, 'urn:IHelloIntf', 'TMyEmployee');

end. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -