User Tools

Site Tools


project_references.htm
Navigation:  Clarion.Net (Clarion#) > Clarion# IDE Tools > Project References >====== Project References ====== Previous pageReturn to chapter overviewNext page

In Clarion# projects, you have an option to add references. In very general terms, references allow you to add additional functionality to your projects from other library sources.

There are two types of references that can be added to any Clarion# project: .(assembly) References and Web References

To add either reference type, open the Projects View and right-click on the Project node. In the popup menu, select either Add Reference or Add Web Reference.

References.jpg

(assembly) References

A standard reference is a reference to any .NET assembly. You will note that there are 4 types of reference sources:

GAC

Lists all assemblies in the Global Assembly Cache, and shows the Reference Name and Version info.

Projects

Lists other projects included in the active solution, and their references.

.NET Assembly Browser

Allows you to browse your work environment and select an assembly reference that may not be included in the GAC.

COM

Lists all COM references installed on your development machine, and allows you to add them to the active project.

Web References

A web reference allows you to use the functionality of a remote XML web service by generating a Clarion# proxy class in your project that allows you to call the XML Web service methods as if the XML Web service were a locally available component.

All you need is the URL of the web service location. As you import the web reference into your program, a file is generated (reference.cln) that contains the exposed methods.

To get started;

1. Right-click on the References node in the Solution Explorer

2. Choose Add Web Reference from the popup menu.

3. When the dialog opens, type or paste in the URL for the service definition that you'll be consuming

4. Once the browser downloads the definition files for the web service, click the Add button. The IDE will create a local proxy class based on the service's WSDL definition to which your client application can bind. This class will be added to your project in a child namespace of your project's namespace. You can see it in the Solution Explorer within a new node that is created (Web References).

The generated class inherits from System.Web.Services.Protocols.SoapHttpClientProtocol, which provides a base set of methods for consuming a Web service. The association with the Web service is defined by a set of attributes that decorate the main class and the proxy class's constructor, which sets the URL for the service into the base class's URL property. If you open the generated Reference.cln file then you'll see something like this:

[System.CodeDom.Compiler.GeneratedCodeAttribute('Clarion', '7.0.0.4007')]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute('code')]
[System.Web.Services.WebServiceBindingAttribute(Name='EndOfDaySoap',
@@Namespace='http://ws.eoddata.com/EndOfDay')]
EndOfDay CLASS(System.Web.Services.Protocols.SoapHttpClientProtocol),NETCLASS,PARTIAL,PUBLIC
!!! <;remarks/>
CONSTRUCT                    PROCEDURE(),PUBLIC
INLINE
CODE
SELF.Url = 'http://ws.eoddata.com/EndOfDay.asmx'
END

At this point, you have a local class that your application can use to access the methods provided by the Web service. Now it's just a matter of creating an instance of the class then use any of the methods provided by the service.

Test PROCEDURE()

EOD EndOfDay

CODE

EOD = NEW EndOfDay()

 !call any EOD instance methods

project_references.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1