我從網上下載http://cc.embarcadero.com/Item/24535什麼是將WSDLIMP.EXE命令行導入到Delphi 7中的BasicHttpBinding WSDL?
更新wsdlimp.exe什麼是WSDLIMP.EXE命令行(命令行選項)導入basicHttpBinding的WSDL導入Delphi 7?我嘗試了基本的語法,但生成的pas文件甚至不會編譯!
我從網上下載http://cc.embarcadero.com/Item/24535什麼是將WSDLIMP.EXE命令行導入到Delphi 7中的BasicHttpBinding WSDL?
更新wsdlimp.exe什麼是WSDLIMP.EXE命令行(命令行選項)導入basicHttpBinding的WSDL導入Delphi 7?我嘗試了基本的語法,但生成的pas文件甚至不會編譯!
命令行僅僅是
wsdlimp -P service.wsdl
無特殊comman行選項是必要的。
問題是wsdl指定了wsHttpBinding而不是basicHttpBinding(這就是爲什麼它不能在Delphi7中編譯)。
我之前發佈的wsdl是一個正確的例子(即使用basicHttpBinding和WCFExtras單個文件端點行爲擴展),這就是爲什麼Jeroen能夠導入它。我無法提供我正在使用的真正的wsdl,但出於法律原因,我只能說一旦我配置服務使用basicHttpBinding而不是wsHttpBinding,並使用WCFExtras提供的單個文件端點行爲(如下所述:How to create a single WSDL file from existing WCF service? ),那麼wsdl可以成功導入到Delphi 7項目中。
+1;感謝有關此更新。很高興知道你要做什麼。 – 2011-04-08 08:26:46
如果您正在以標準方式導入使用Visual Studio 2005或更高版本生成的WSDL,則需要更新版本的Delphi WSDL導入程序posted at codecentralJean-Marie Babet。
很少有語言可以導入您在WSDL中可以執行的所有操作,因此您可能會遇到一些細節問題。 他是那些對WSDL內部人最爲了解並且在Embarcadero論壇上很活躍的人,所以在那裏也可以提出同樣的問題。
舊的Delphi WSDL導入程序只做了RCP風格的SOAP,而新的也支持文檔/字面風格。
另請參閱this thread。
記憶擔任我的權利:這一特定問題在Delphi 2007年解決
編輯:
我參加了一個快捷方式與德爾福XE WSDL進口商通過IDE注意到選項。使用
選項:
-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.
嗨Jeroen,對不起,我不能接受,我一定需要更新版本的德爾福。我聽說過那些用Delphi 7實現了我之後的人,以及http://cc.embarcadero.com/item/24535更新的wsdlimp.exe。我想我已經修改了我的WCF服務以生成一個用於BasicHttpBinding的「flat wsdl」,所以我只需要將它「導入」到pas文件中。我想要的是wsdlimp命令行(帶有選項),它將避免複合類型和Delphi 7不喜歡的其他任何東西。我知道這是可以做到的。 – Sam 2011-04-05 10:24:18
@Sam:我不知道WSDL導入器已經聯機;我會把它放在我的答案中。當我有更多時間的時候,我也會嘗試爲你提供一個命令行,但是這更像是在本週結束時。 – 2011-04-05 11:16:06
你可以發佈你使用的網址或wsdl嗎? – 2011-04-05 09:32:22