什么是将BasicHttpBinding WSDL导入Delphi 7的WSDLIMP.EXE命令行?

时间:2011-04-05 07:50:09

标签: delphi soap wsdl delphi-7

我已从http://cc.embarcadero.com/Item/24535

下载了更新的wsdlimp.exe

将BasicHttpBinding WSDL导入Delphi 7的WSDLIMP.EXE命令行(哪些命令行选项)是什么?我尝试了基本语法,但生成的pas文件甚至都不会编译!

2 个答案:

答案 0 :(得分:1)

如果要以标准方式导入使用Visual Studio 2005或更高版本生成的WSDL,则posted at codecentral需要更新版本的Delphi WSDL导入器为Jean-Marie Babet

很少有语言可以导入您在WSDL中可以执行的所有操作,因此您可能会对某些细节感到不快。 他是最了解WSDL内脏并且在Embarcadero论坛上活跃的人,因此也可以在那里提出同样的问题。

旧的Delphi WSDL导入器只执行RCP样式的SOAP,而新的也支持文档/文字样式。

另见this thread

记忆力对我有用:特殊问题在Delphi 2007中得到了解决。

编辑:

我通过IDE使用Delphi XE WSDL导入程序获取了一个快捷方式,并注明了这些选项。

使用的选项:

-Oa
-Od
-Oe
-Of
-Oh
-Oi
-Oj
-Oo
-Op
-Ot
-Ou
-Ov
-Ox

导入的文件:

// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : C:\develop\codeplex.svn\bo\Native\Delphi\Apps\WSDLSampleImport\wsdl\sampleWsdl.wsdl
//  >Import : C:\develop\codeplex.svn\bo\Native\Delphi\Apps\WSDLSampleImport\wsdl\sampleWsdl.wsdl>0
//  >Import : C:\develop\codeplex.svn\bo\Native\Delphi\Apps\WSDLSampleImport\wsdl\sampleWsdl.wsdl>1
//  >Import : C:\develop\codeplex.svn\bo\Native\Delphi\Apps\WSDLSampleImport\wsdl\sampleWsdl.wsdl>2
// Encoding : utf-8
// Version  : 1.0
// (4/5/2011 1:23:46 PM - - $Rev: 34800 $)
// ************************************************************************ //

unit sampleWsdl;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_NLBL = $0004;
  IS_REF  = $0080;


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 Embarcadero 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"[Gbl]
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"[Gbl]

  CompositeType2       = class;                 { "http://schemas.datacontract.org/2004/07/WCFService"[GblCplx] }
  CompositeType        = class;                 { "http://schemas.datacontract.org/2004/07/WCFService"[GblElm] }



  // ************************************************************************ //
  // XML       : CompositeType, global, <complexType>
  // Namespace : http://schemas.datacontract.org/2004/07/WCFService
  // ************************************************************************ //
  CompositeType2 = class(TRemotable)
  private
    FBoolValue: Boolean;
    FBoolValue_Specified: boolean;
    FStringValue: string;
    FStringValue_Specified: boolean;
    procedure SetBoolValue(Index: Integer; const ABoolean: Boolean);
    function  BoolValue_Specified(Index: Integer): boolean;
    procedure SetStringValue(Index: Integer; const Astring: string);
    function  StringValue_Specified(Index: Integer): boolean;
  published
    property BoolValue:   Boolean  Index (IS_OPTN) read FBoolValue write SetBoolValue stored BoolValue_Specified;
    property StringValue: string   Index (IS_OPTN or IS_NLBL) read FStringValue write SetStringValue stored StringValue_Specified;
  end;



  // ************************************************************************ //
  // XML       : CompositeType, global, <element>
  // Namespace : http://schemas.datacontract.org/2004/07/WCFService
  // ************************************************************************ //
  CompositeType = class(CompositeType2)
  private
  published
  end;


  // ************************************************************************ //
  // Namespace : http://tempuri.org/
  // soapAction: http://tempuri.org/IService1/%operationName%
  // transport : http://schemas.xmlsoap.org/soap/http
  // style     : document
  // use       : literal
  // binding   : BasicHttpBinding_IService1
  // service   : Service1
  // port      : BasicHttpBinding_IService1
  // URL       : http://localhost:8732/Design_Time_Addresses/WCFService/Service1/
  // ************************************************************************ //
  IService1 = interface(IInvokable)
  ['{33335FCB-4DFB-92EA-D063-AF625AFEE0FC}']
    function  GetData(const value: string): string; stdcall;
    function  GetDataUsingDataContract(const composite: CompositeType2): CompositeType2; stdcall;
  end;

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


implementation
  uses SysUtils;

function GetIService1(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IService1;
const
  defWSDL = 'C:\develop\codeplex.svn\bo\Native\Delphi\Apps\WSDLSampleImport\wsdl\sampleWsdl.wsdl';
  defURL  = 'http://localhost:8732/Design_Time_Addresses/WCFService/Service1/';
  defSvc  = 'Service1';
  defPrt  = 'BasicHttpBinding_IService1';
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 IService1);
    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;


procedure CompositeType2.SetBoolValue(Index: Integer; const ABoolean: Boolean);
begin
  FBoolValue := ABoolean;
  FBoolValue_Specified := True;
end;

function CompositeType2.BoolValue_Specified(Index: Integer): boolean;
begin
  Result := FBoolValue_Specified;
end;

procedure CompositeType2.SetStringValue(Index: Integer; const Astring: string);
begin
  FStringValue := Astring;
  FStringValue_Specified := True;
end;

function CompositeType2.StringValue_Specified(Index: Integer): boolean;
begin
  Result := FStringValue_Specified;
end;

initialization
  { IService1 }
  InvRegistry.RegisterInterface(TypeInfo(IService1), 'http://tempuri.org/', 'utf-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IService1), 'http://tempuri.org/IService1/%operationName%');
  InvRegistry.RegisterInvokeOptions(TypeInfo(IService1), ioDocument);
  { IService1.GetData }
  InvRegistry.RegisterMethodInfo(TypeInfo(IService1), 'GetData', '',
                                 '[ReturnName="GetDataResult"]', IS_OPTN or IS_NLBL);
  InvRegistry.RegisterParamInfo(TypeInfo(IService1), 'GetData', 'value', '',
                                '', IS_NLBL);
  InvRegistry.RegisterParamInfo(TypeInfo(IService1), 'GetData', 'GetDataResult', '',
                                '', IS_NLBL);
  { IService1.GetDataUsingDataContract }
  InvRegistry.RegisterMethodInfo(TypeInfo(IService1), 'GetDataUsingDataContract', '',
                                 '[ReturnName="GetDataUsingDataContractResult"]', IS_OPTN or IS_NLBL);
  InvRegistry.RegisterParamInfo(TypeInfo(IService1), 'GetDataUsingDataContract', 'composite', '',
                                '[Namespace="http://schemas.datacontract.org/2004/07/WCFService"]', IS_NLBL);
  InvRegistry.RegisterParamInfo(TypeInfo(IService1), 'GetDataUsingDataContract', 'GetDataUsingDataContractResult', '',
                                '[Namespace="http://schemas.datacontract.org/2004/07/WCFService"]', IS_NLBL);
  RemClassRegistry.RegisterXSClass(CompositeType2, 'http://schemas.datacontract.org/2004/07/WCFService', 'CompositeType2', 'CompositeType');
  RemClassRegistry.RegisterXSClass(CompositeType, 'http://schemas.datacontract.org/2004/07/WCFService', 'CompositeType');

end.

答案 1 :(得分:1)

命令行只是

wsdlimp -P service.wsdl

不需要特殊的命令行选项。

问题是wsdl指定了wsHttpBinding而不是basicHttpBinding(这就是为什么它不能在Delphi7中编译)。

我之前发布的wsdl是一个恰好正确的旧例子(即使用basicHttpBinding和WCFExtras单文件端点行为扩展),这就是Jeroen能够导入它的原因。我无法提供真正的wsdl我出于法律原因而工作,但足以说一旦我将服务配置为使用basicHttpBinding而不是wsHttpBinding,并使用了WCFExtras提供的单文件端点行为(如下所述:{ {3}}),然后可以将wsdl成功导入到Delphi 7项目中。