var
ITelWebServiceSoap :TelWebServiceSoap;
RoutesObj : ArrayOfRoute;
error : ErrorInfo;
begin
ITelWebServiceSoap :=(HTTPRIO1 as TelWebServiceSoap);//这样转一下
error:=ITelWebServiceSoap.CheckUser('aa','aa');
Memo1.Lines.Clear;
if error.m_bERROR=false then
begin
Memo1.Lines.Add(错误信息!'+error.m_ERROR_INFO);
exit;
end;
ITelWebServiceSoap.GetRouteListByCode('aa',2,Surveyid.Text,error,RoutesObj);
if error.m_bERROR=false then //---³ö´í ûÓлñÈ¡µ½Êý¾Ý
begin
Memo1.Lines.Add(取得数据:'+error.m_ERROR_INFO);
end
else
begin
Memo1.Lines.Add(IntToStr(Length(RoutesObj)));
end;
ITelWebServiceSoap.Exit;
end;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,SoapHTTPClient,InvokeRegistry, Types, XSBuiltIns;
type
ExampleSoap = interface(IInvokable)
['{444725B4-3750-586C-5497-8EE30CDE10B9}']
function HelloWorld: WideString; stdcall;
function getStr(const s: WideString): WideString; stdcall;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
X :THTTPRio;
InterfaceVariable: ExampleSoap;
begin
X :=THTTPRio.Create(nil);
x.HTTPWebNode.UseUTF8InHeader:=true;
x.WSDLLocation:='http://localhost/MyWebService/Example.asmx?wsdl';
InterfaceVariable := X as ExampleSoap;
showmessage(InterfaceVariable.HelloWorld);
showmessage(InterfaceVariable.getStr('hello world'));
x.Free;
end;
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/MyWebService/Example.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2007-2-28 12:19:12 - 1.33.2.5)
// ************************************************************************ //
// ************************************************************************ //
// 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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : ExampleSoap
// service : Example
// port : ExampleSoap
// URL : http://localhost/MyWebService/Example.asmx
// ************************************************************************ //
ExampleSoap = interface(IInvokable)
['{444725B4-3750-586C-5497-8EE30CDE10B9}']
function HelloWorld: WideString; stdcall;
function getStr(const s: WideString): WideString; stdcall;
end;
function GetExampleSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): ExampleSoap;
implementation
function GetExampleSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ExampleSoap;
const
defWSDL = 'http://localhost/MyWebService/Example.asmx?wsdl';
defURL = 'http://localhost/MyWebService/Example.asmx';
defSvc = 'Example';
defPrt = 'ExampleSoap';
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 ExampleSoap);
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;