.Net Runtime Library for Delphi
Close
Import WSDL/XML Webservices
Describes how to import Web Service Description language file/url or XML schema that describes a web service and generates delphi classes from the types of the imported wsdl assemblies.
System_CAPS_note Note

Before you can use this utility to generate delphi classes from wsdl assemblies, you must have Delphi Host Class Library and Delphi Framework Class Library installed.

Follow the steps below to import WSDL/XML Web Service and generate Delphi Classes from the imported Wsdl Assemblies:
Step 1: Specify the file or Url location of the Web Service Description Language (WSDL). On this screen, you have the option to specify the SOAP protocol version that is used to communicate with the WSDL document or XML Web services. The following are the versions of the SOAP protocol:

a.       Process only WSDL Binding extensions for SOAP 1.1 Protocol : The process communicates with the service using SOAP 1.1 protocol.

b.    Process only WSDL Binding extensions for SOAP 1.2 Protocol : The process communicates with the service using SOAP 1.2 protocol.

c.    Process only WSDL Binding extensions for HTTP POST Protocol : The process communicates with the service using HTTP POST protocol.

d.     Process only WSDL Binding extensions for HTTP GET Protocol : The process communicates with the service using HTTP GET protocol.

e.    Process only WSDL Binding extensions for HTTP SOAP Protocol : The process communicates with the service using HTTP SOAP protocol.

Click the Next button and go to step 2.

Step 2: This screen displays the loaded wsdl assemblies in the WSDL Assembly Names list. The assemblies on the list can be removed by selecting the assemblies to remove and subsequently clicking on the remove button  .

The right part of the screen above displays the properties of the wsdl assemblies to be imported.
 It is recommended to change the unit name of the WSDL assembly since the assembly name of the wsdl is randomly generated. For instance, the unit name for the wsdl assembly above has been changed from obmnycr5 to WebService1.
Click the Next button and go to step 3.

Step 3: This screen allows you to specify which types and the members of the types of the wsdl assemblies you want to import. The members of the type includes the Constructors, Fields, Properties, Methods and Events. In the screen below, the Service1 type has been selected and atleast one member item has also been selected for each member of the type.

You can change the class names of the assembly types by clicking on the Modify Class Name button. The screen below will be shown where you can change the default class names of the assembly types.

 

Click the Next button and go to step 4.

Step 4: This screen allows you to specify the directory where the generated Delphi files will be stored after import. You can also select the option(s) for importing the assembly types. These options are:

a.     Separate larger generated Delphi units into different units: Selecting this option allows the process to automatically separates the delphi unit to be generated into smaller units if the unit to be generated from the assembly types will be larger and contains volumnous lines of code making it difficult to debug in delphi.

b.   Optimize process: Selecting this option allows the process to perform a number of delphi code optimization such as excluding public field members of the selected types to be imported and prevent creating full class definition for types without any members.

c.      Search and include type references in other assemblies to be imported: Selecting this option allows the process to search for any dependencies in the list of assemblies to be imported and use the referenced type rather than specifying a default value or creating a class for the referenced type.

Click the Finish Button to start the process.

After the process is complete, atleast 2 files or delphi units will have been generated for each assembly file imported. These units are: 

·        Constants Unit : This delphi unit contains the string constant variables of the assembly ID, the WSDL Url or File Location and the fullnames of the .net assembly types imported. This unit file name is the combination of the name of the class unit and Const.

The example below shows the content of the constant unit generated from the wsdl assembly obmnycr5 .

Delphi
unit WebService1Const; interface const sC_WebService1_Asm_ID = 'a1e3fcac-57aa-40a9-9030-c84c8834c8e5'; sC_WebService1_sC_WSDLLocation = 'http://localhost:14199/Service1.asmx'; sC_Service1 = 'Service1'; implementation end.











 

 

·      Class Unit(s) : Contains the types and it members imported from the wsdl assembly. More than one class unit can be generated if the option "Separate larger generated Delphi units into different units" is selected and the imported wsdl assembly will result in a larger and voluminous lines of code for a single unit.

The example below shows the content of the Class Unit generated from the wsdl Assembly obmnycr5.

Delphi
unit WebService1; {$WARN SYMBOL_PLATFORM OFF} {$WARN HIDING_MEMBER OFF} interface uses CNClrLib.Host, WebService1Enums, CNClrLib.EnumTypes, WebService1Const; type { TService1 } TService1 = Class(TClrBaseObject) private function Get_AllowAutoRedirect: Boolean; procedure Set_AllowAutoRedirect(Value: Boolean); public constructor Create; function HelloWorld: string; property AllowAutoRedirect: Boolean read Get_AllowAutoRedirect write Set_AllowAutoRedirect; end; function GetWebService1Assembly: TClrAssembly; implementation function GetWebService1Assembly: TClrAssembly; begin Result := TClrAssembly.GetRegisterAssembly(sC_WebService1_Asm_ID); end; { TService1 } constructor TService1.Create; begin inherited Create(sC_Service1, nil) end; function TService1.HelloWorld: string; begin Result := InvokeMethod('HelloWorld'); end; function TService1.Get_AllowAutoRedirect: Boolean; begin Result := GetPropertyValue('AllowAutoRedirect'); end; procedure TService1.Set_AllowAutoRedirect(Value: Boolean); begin SetPropertyValue('AllowAutoRedirect', Value); end; initialization TClrAssembly.RegisterAssembly(sC_WebService1_Asm_ID, sC_WebService1_sC_WSDLLocation, ltWSDL, pnSoap12); end.



























































 

·       Enums Unit : This delphi unit contains the enumeration types defined in the imported wsdl assembly types. If the assemblies to be imported do not have any enumeration types, this unit will not be generated. This unit file name is the combination of the name of the class unit and Enums.