首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi导入wsdl资料后接口函数改变

2013-01-06 
delphi导入wsdl文件后接口函数改变在delphi2007中导入C#写的webservice服务(通过保存wsdl成asmx文件后导入

delphi导入wsdl文件后接口函数改变
在delphi2007中导入C#写的webservice服务(通过保存wsdl成asmx文件后导入)导入后生成的接口函数改变,请高手帮忙看一下。之前也到过类似的,没有这种问题。不只是什么原因。wsdl内容楼下贴上。
[解决办法]
将你的描述文件保存为wsdl或者xml,格式为utf-8,然后使用delphi的Wsdl import wizard可以导入,pas文件如下:
unit ccc;

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"

  GetVehXxResult       = class;                 { "http://127.0.0.1/" }
  GetVehDataSetResult  = class;                 { "http://127.0.0.1/" }
  GetVehSiteResult     = class;                 { "http://127.0.0.1/" }
  GetVehXxTestResult   = class;                 { "http://127.0.0.1/" }



  // ************************************************************************ //
  // Namespace : http://127.0.0.1/
  // ************************************************************************ //
  GetVehXxResult = class(TRemotable)
  private
    Fschema: WideString;
  published
    property schema: WideString read Fschema write Fschema;
  end;



  // ************************************************************************ //
  // Namespace : http://127.0.0.1/
  // ************************************************************************ //
  GetVehDataSetResult = class(TRemotable)
  private
    Fschema: WideString;
  published
    property schema: WideString read Fschema write Fschema;
  end;



  // ************************************************************************ //
  // Namespace : http://127.0.0.1/
  // ************************************************************************ //
  GetVehSiteResult = class(TRemotable)


  private
    Fschema: WideString;
  published
    property schema: WideString read Fschema write Fschema;
  end;



  // ************************************************************************ //
  // Namespace : http://127.0.0.1/
  // ************************************************************************ //
  GetVehXxTestResult = class(TRemotable)
  private
    Fschema: WideString;
  published
    property schema: WideString read Fschema write Fschema;
  end;


  // ************************************************************************ //
  // Namespace : http://127.0.0.1/
  // soapAction: http://127.0.0.1/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // binding   : ServiceSoap
  // service   : Service
  // port      : ServiceSoap
  // URL       : http://192.168.2.4/cmnservices/service.asmx
  // ************************************************************************ //
  ServiceSoap = interface(IInvokable)
  ['{1552EAFC-221D-F78F-A1F5-A9C424BE8571}']
    function  GetIP: WideString; stdcall;
    function  GetDate: WideString; stdcall;
    procedure GetVehXx(const hpzl: WideString; const hphm: WideString; const sn: WideString; const jczbh: WideString; out GetVehXxResult: GetVehXxResult; out err: WideString); stdcall;
    function  GetVehDataSet(const strSql: WideString; const sn: WideString; const jczbh: WideString): GetVehDataSetResult; stdcall;
    procedure GetVehSite(const hpzl: WideString; const hphm: WideString; const sn: WideString; const jczbh: WideString; out GetVehSiteResult: GetVehSiteResult; out err: WideString); stdcall;
    function  SetWriteJYJGXx(const jczbh: WideString; const jcxbh: WideString; const hpzl: WideString; const hphm: WideString; const clsbdh: WideString; const jyjg: WideString; const jyrq: WideString; const kssj: WideString; const jssj: WideString; const cjdw: WideString;
                             const sn: WideString): WideString; stdcall;
    function  SetWriteJYJG(const jczbh: WideString; const hpzl: WideString; const hphm: WideString; const clsbdh: WideString; const jyjg: WideString; const jyrq: WideString; const cjdw: WideString; const sn: WideString): WideString; stdcall;
    function  GetVehXxTest(const hpzl: WideString; const hphm: WideString; const sn: WideString; const jczbh: WideString): GetVehXxTestResult; stdcall;


  end;

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


implementation

function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
  defWSDL = 'C:\Documents and Settings\Administrator\桌面\ccc.wsdl';
  defURL  = 'http://192.168.2.4/cmnservices/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;
  if HTTPRIO = nil then
    RIO := THTTPRIO.Create(nil)
  else
    RIO := HTTPRIO;
  try
    Result := (RIO as ServiceSoap);
    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(ServiceSoap), 'http://127.0.0.1/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ServiceSoap), 'http://127.0.0.1/%operationName%');
  RemClassRegistry.RegisterXSClass(GetVehXxResult, 'http://127.0.0.1/', 'GetVehXxResult');
  RemClassRegistry.RegisterXSClass(GetVehDataSetResult, 'http://127.0.0.1/', 'GetVehDataSetResult');
  RemClassRegistry.RegisterXSClass(GetVehSiteResult, 'http://127.0.0.1/', 'GetVehSiteResult');
  RemClassRegistry.RegisterXSClass(GetVehXxTestResult, 'http://127.0.0.1/', 'GetVehXxTestResult');

end.

热点排行