请问为什么调用c#写的webservice时,调试的时候在下面的这段出现了错误
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');错误提示是access violation。
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');错误提示是access violation。
-----------------------------------------------------------------------
unit Service;interfaceuses InvokeRegistry, 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"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:string - "http://tempuri.org/"
// !:base64Binary - "http://www.w3.org/2001/XMLSchema" GetDataSetResult = class; { "http://tempuri.org/" } // ************************************************************************ //
// Namespace : http://tempuri.org/
// ************************************************************************ //
GetDataSetResult = class(TRemotable)
private
Fs_schema: String;
published
property s_schema: String read Fs_schema write Fs_schema;
end;
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ServiceSoap
// service : Service
// port : ServiceSoap
// URL : http://localhost/mywebservice/Service.asmx
// ************************************************************************ //
ServiceSoap = interface(IInvokable)
['{77573149-9C57-FA51-F11F-EFD527C91BD9}']
function Linking: String; stdcall;
function GetDataSet(const sqlstr: String; const userid: Integer; const pwd: String): GetDataSetResult; stdcall;
function Search(const carid: String): TByteDynArray; stdcall;
procedure Add(const id: String; const Image: TByteDynArray); stdcall;
end;function GetServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''): ServiceSoap;
implementation
uses SOAPHTTPClient;function GetServiceSoap(UseWSDL: Boolean; Addr: string): ServiceSoap;
const
defWSDL = 'http://localhost/mywebservice/Service.asmx?WSDL';
defURL = 'http://localhost/mywebservice/Service.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
RIO := THTTPRIO.Create(nil);
try
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
Result := (RIO as ServiceSoap);
finally
if Result = nil then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInvokeOptions(TypeInfo(ServiceSoap),ioDocument);//就在这句出错了.错误提示:"access violation at 0x004a472a:other of address 0x004a472a"
InvRegistry.RegisterInterface(TypeInfo(ServiceSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://tempuri.org/%operationName%');
RemClassRegistry.RegisterXSClass(GetDataSetResult, 'http://tempuri.org/', 'GetDataSetResult');
end.
------------------------------------------------------------------------unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Rio, SOAPHTTPClient, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
HTTPRIO1: THTTPRIO;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses Service;{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
Web_Search:ServiceSoap;
begin
Web_Search:=HTTPRIO1 as ServiceSoap;
try
Web_Search.GetDataSet(Edit1.Text ,1,'1')
except
on E: Exception do Exit
end;
end;end.