偶最近在开发一个短信接口程序,对方提供的是一个web service接口,接口如下:
unit SMSHTTP;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
GetInMessageResult = class; { "http://localhost/SMSHTTP" }
{ "http://localhost/SMSHTTP" }
InMessageType = (All, Processed, UnProcessed);
// Namespace : http://localhost/SMSHTTP
// ************************************************************************ //
GetInMessageResult = class(TRemotable)
private
Fschema: WideString;
published
property schema: WideString read Fschema write Fschema;
end;************************************** //
SMSServiceSoap = interface(IInvokable)
['{5CE582F3-E623-1D01-F61E-B1B07FF45F78}']
function GetInMessage(const username: WideString; const password: WideString; const type_: InMessageType): GetInMessageResult; stdcall;function GetSMSServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): SMSServiceSoap;
implementationfunction GetSMSServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): SMSServiceSoap;
const
defWSDL = 'http://218.15.153.142/SMSHTTP/SMSHTTP.asmx?WSDL';
defURL = http://218.15.153.142/SMSHTTP/SMSHTTP.asmx';
defSvc = 'SMSService';
defPrt = 'SMSServiceSoap';
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 SMSServiceSoap);
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(SMSServiceSoap), 'http://localhost/SMSHTTP', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(SMSServiceSoap), 'http://localhost/SMSHTTP/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(SMSServiceSoap), ioDocument);
InvRegistry.RegisterExternalParamName(TypeInfo(SMSServiceSoap), 'GetInMessage', 'type_', 'type');
InvRegistry.RegisterExternalParamName(TypeInfo(SMSServiceSoap), 'GetInMessageString', 'type_', 'type');
RemClassRegistry.RegisterXSInfo(TypeInfo(InMessageType), 'http://localhost/SMSHTTP', 'InMessageType');
RemClassRegistry.RegisterXSClass(GetInMessageResult, 'http://localhost/SMSHTTP', 'GetInMessageResult');
end.请教各位,我调用了getInMessage方法后,怎么将返回的结果GetInMessageResult 类型的数据转换为我所需要的数据格式,转换到TClientDataSet中。
GetInMessageResult类型,包括返回的记录条数和字段数目,以及各个字段的值,谢请各位多多帮助,不然我就要被炒鱿鱼了。555555555
unit SMSHTTP;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
type
GetInMessageResult = class; { "http://localhost/SMSHTTP" }
{ "http://localhost/SMSHTTP" }
InMessageType = (All, Processed, UnProcessed);
// Namespace : http://localhost/SMSHTTP
// ************************************************************************ //
GetInMessageResult = class(TRemotable)
private
Fschema: WideString;
published
property schema: WideString read Fschema write Fschema;
end;************************************** //
SMSServiceSoap = interface(IInvokable)
['{5CE582F3-E623-1D01-F61E-B1B07FF45F78}']
function GetInMessage(const username: WideString; const password: WideString; const type_: InMessageType): GetInMessageResult; stdcall;function GetSMSServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): SMSServiceSoap;
implementationfunction GetSMSServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): SMSServiceSoap;
const
defWSDL = 'http://218.15.153.142/SMSHTTP/SMSHTTP.asmx?WSDL';
defURL = http://218.15.153.142/SMSHTTP/SMSHTTP.asmx';
defSvc = 'SMSService';
defPrt = 'SMSServiceSoap';
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 SMSServiceSoap);
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(SMSServiceSoap), 'http://localhost/SMSHTTP', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(SMSServiceSoap), 'http://localhost/SMSHTTP/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(SMSServiceSoap), ioDocument);
InvRegistry.RegisterExternalParamName(TypeInfo(SMSServiceSoap), 'GetInMessage', 'type_', 'type');
InvRegistry.RegisterExternalParamName(TypeInfo(SMSServiceSoap), 'GetInMessageString', 'type_', 'type');
RemClassRegistry.RegisterXSInfo(TypeInfo(InMessageType), 'http://localhost/SMSHTTP', 'InMessageType');
RemClassRegistry.RegisterXSClass(GetInMessageResult, 'http://localhost/SMSHTTP', 'GetInMessageResult');
end.请教各位,我调用了getInMessage方法后,怎么将返回的结果GetInMessageResult 类型的数据转换为我所需要的数据格式,转换到TClientDataSet中。
GetInMessageResult类型,包括返回的记录条数和字段数目,以及各个字段的值,谢请各位多多帮助,不然我就要被炒鱿鱼了。555555555
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货