忍
忍我
Unregistered / Unconfirmed
GUEST, unregistred user!
delphi 调用web service
delphi 调用代码:
procedure TForm1.Button1Click(Sender: TObject);
var
InterfaceVariable: AmrServiceRemoteHandler;
i:integer;
X :THTTPRio;
ss:widestring;
begin
X := THTTPRio.Create(nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
x.URL:= 'http://211.144.32.182:8080/amr/services/AmrService?wsdl';
X.Service:='AmrServiceRemoteHandlerService';
X.Port := 'AmrService';
InterfaceVariable := X as AmrServiceRemoteHandler;
ss:='000612302759';
i:=InterfaceVariable.getRecentlyVa(ss);
self.Label_return_value.Caption:=inttostr(i);
X.free;
end;
装载的wsdl
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : C:/Documents and Settings/yang/桌面/主站问题/AmrService.wsdl
// Encoding : UTF-8
// Version : 1.0
// (2006-7-19 20:07:29 - 1.33.2.5)
// ************************************************************************ //
unit AmrService;
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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:short - "http://www.w3.org/2001/XMLSchema"
ArrayOfString = array of WideString; { "http://t645.server.amr" }
// ************************************************************************ //
// Namespace : http://t645.server.amr
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : AmrServiceSoapBinding
// service : AmrServiceRemoteHandlerService
// port : AmrService
// URL : http://211.144.32.182:8080/amr/services/AmrService
// ************************************************************************ //
AmrServiceRemoteHandler = interface(IInvokable)
['{2D20F96A-140F-0C62-E3F4-947D5172D05C}']
function getActiveSpotList: ArrayOfString; stdcall;
function getRecentlyVa(const equipment_id: WideString): Smallint; stdcall;
end;
function GetAmrServiceRemoteHandler(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): AmrServiceRemoteHandler;
implementation
function GetAmrServiceRemoteHandler(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): AmrServiceRemoteHandler;
const
defWSDL = 'C:/Documents and Settings/yang/桌面/主站问题/AmrService.wsdl';
defURL = 'http://211.144.32.182:8080/amr/services/AmrService';
defSvc = 'AmrServiceRemoteHandlerService';
defPrt = 'AmrService';
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 AmrServiceRemoteHandler);
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(AmrServiceRemoteHandler), 'http://t645.server.amr', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(AmrServiceRemoteHandler), '');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'http://t645.server.amr', 'ArrayOfString');
end.
delphi调用后,死掉了,不知道什么问题.
delphi 调用代码:
procedure TForm1.Button1Click(Sender: TObject);
var
InterfaceVariable: AmrServiceRemoteHandler;
i:integer;
X :THTTPRio;
ss:widestring;
begin
X := THTTPRio.Create(nil);
X.HTTPWebNode.UseUTF8InHeader := true ;
x.URL:= 'http://211.144.32.182:8080/amr/services/AmrService?wsdl';
X.Service:='AmrServiceRemoteHandlerService';
X.Port := 'AmrService';
InterfaceVariable := X as AmrServiceRemoteHandler;
ss:='000612302759';
i:=InterfaceVariable.getRecentlyVa(ss);
self.Label_return_value.Caption:=inttostr(i);
X.free;
end;
装载的wsdl
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : C:/Documents and Settings/yang/桌面/主站问题/AmrService.wsdl
// Encoding : UTF-8
// Version : 1.0
// (2006-7-19 20:07:29 - 1.33.2.5)
// ************************************************************************ //
unit AmrService;
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.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"
// !:short - "http://www.w3.org/2001/XMLSchema"
ArrayOfString = array of WideString; { "http://t645.server.amr" }
// ************************************************************************ //
// Namespace : http://t645.server.amr
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// binding : AmrServiceSoapBinding
// service : AmrServiceRemoteHandlerService
// port : AmrService
// URL : http://211.144.32.182:8080/amr/services/AmrService
// ************************************************************************ //
AmrServiceRemoteHandler = interface(IInvokable)
['{2D20F96A-140F-0C62-E3F4-947D5172D05C}']
function getActiveSpotList: ArrayOfString; stdcall;
function getRecentlyVa(const equipment_id: WideString): Smallint; stdcall;
end;
function GetAmrServiceRemoteHandler(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): AmrServiceRemoteHandler;
implementation
function GetAmrServiceRemoteHandler(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): AmrServiceRemoteHandler;
const
defWSDL = 'C:/Documents and Settings/yang/桌面/主站问题/AmrService.wsdl';
defURL = 'http://211.144.32.182:8080/amr/services/AmrService';
defSvc = 'AmrServiceRemoteHandlerService';
defPrt = 'AmrService';
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 AmrServiceRemoteHandler);
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(AmrServiceRemoteHandler), 'http://t645.server.amr', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(AmrServiceRemoteHandler), '');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'http://t645.server.amr', 'ArrayOfString');
end.
delphi调用后,死掉了,不知道什么问题.