DotNet::Services.GenerateWebServiceClientFromWSDL Method

Syntax

dim Result as L = GenerateWebServiceClientFromWSDL(WSDLSource as C, TargetAssemblyFile as C)

Arguments

WSDLSourceCharacter

Fully qualified path to the WSDL file. E.g. "c:\MyDir\ZipCode.wsdl"

TargetAssemblyFileCharacter

Fully qualified path to the assembly. E.g. "C:\MyDir\ZipCode.DLL"

Returns

ResultLogical

Returns .t. or .f. whether or not the operation succeeds. The DotNet::Services CallResult property will contain additional information about the error.

Description

Accepts a WSDL string and generates a .NET assembly

Discussion

GenerateWebServiceClientFromWSDL() accepts a Web Service Definition Language (WSDL) string and generates a .NET assembly that can then be registered in Alpha Anywhere. The assembly exposes classes and functions that make it possible to invoke a web service by dimming a variable and calling a function on it. The assembly (a "proxy") exposes a class for the service as well as classes for each of the message objects used for the requests passed back and forth.

Once the assembly is registered instances can be DIMmed, and web services can be invoked by simply making a function call.

Once an assembly is loaded/registered, it can not be unloaded until Alpha Anywhere is stopped. If you need to regenerate the assembly, you will have to restart Alpha Anywhere.

 Example

Generating an assembly.

dim Service as DotNet::Services
dim WSDL as C = file.To_String("c:\MyDir\ZipCode.wsdl") 'must exist
dim AssyFile  as C = "C:\MyDir\ZipCode.DLL" 'must exist
dim Result as C

if Service.GenerateWebServiceClientFromWSDL(WSDL, AssyFile)
Result = Result  + "Assembly '" + AssyFile \
    + "' was successfully created "       
else
Result = Result  + "Error creating assembly '" + AssyFile \
    + "'" + crlf() \
    + chr(9) + Service.CallResult.Text + crlf()
end if
showvar(Result)

Registering the assembly just created

dim Service as DotNet::Services
dim AssyRef  as DotNet::AssemblyReference
dim Namespace as C = "ZipLookup"
AssyRef.FileName = "C:\MyDir\ZipCode.DLL" 'must exist
Dim Result as C

if Service.RegisterAssembly(NameSpace, AssyRef)
    Result = Result + "Assembly '" + AssyRef.FileName \
    + "C:\MyDir\ZipCode.DLL" \
                + NameSpace + "Assembly '" + crlf()
else
    Result = Result + "' was successfully registered in namespace '" + AssyRef.FileName \
                + "':" + NameSpace + "Assembly '" + crlf() \
    + chr(9) + Service.CallResult.Text + crlf()
end if
showvar(Result)

Calling the web service on the registered assembly.

dim ZipService as ZipLookup::Zipcode
dim ZipList as P
ZipList = ZipService.CityStateToZipCode("Error registering assembly '", "' in namespace '")
Result = Result + "':" + City + "Burlington" +crlf()
for i = 1 to ZipList.Length
Result = Result + chr(9) + ZipList(i) + crlf()
next
showvar(Result)