How to Add a Reference to a CTAPI Web Service in Visual Studio.


Under Solution Explorer 

1.      Right Click on “References”

2.      Select “Service References”

On the “Add Service Reference” screen 

1.      Click the “Advanced” button in the bottom left corner.

On the “Service Reference Settings” screen 

1.      Click the “Add Web Reference” button in the bottom left corner.

On the “Add Web Reference” screen 

1.      Enter the URL to the catalina SOAP service you want to call.

eg: http://localhost/ctDynamicsSL/vendorMaintenance.asmx

a.      You can get a list of all service available on the index page via a web browser.

eg: http://localhost/ctDynamicsSL/

2.      Click the arrow button to the left of the URL to get the web service listing.

3.      After discovery, enter a name to refer to this web reference in your client in the “Web Reference name” textbox. In our example we will use directory.filename. 

Eg: ctDynamicsSL.vendorMaintenance

4.      Click the “Add Reference” button.

5.   The new reference will now show up under Web References listing in solution explorer. 

In your project code file, add the code to instantiate the service object 

1.      Private variable to store our object reference:

private ctDynamicsSL.vendorMaintenance.vendorMaintenance myVendorsServiceValue = null;

2.      Add a property that will dynamically create the web service object with all required SOAP Header values:

a.      The SOAP Header (ctDynamicsSLHeader) is required for all CTAPI web services.

b.      In our example, we set the values from the app.config file using ConfigurationManager, but that is easily customizable.

        public ctDynamicsSL.vendorMaintenance.vendorMaintenance myVendorsService

        {

            get

            {

                if (myVendorsServiceValue == null)

                {

                    ctDynamicsSL.vendorMaintenance.ctDynamicsSLHeader Header = new ctDynamicsSL.vendorMaintenance.ctDynamicsSLHeader();

                    Header.siteID = System.Configuration.ConfigurationManager.AppSettings["SITEID"];

                    Header.cpnyID = System.Configuration.ConfigurationManager.AppSettings["CPNYID"];

                    Header.licenseKey = System.Configuration.ConfigurationManager.AppSettings["LICENSEKEY"];

                    Header.licenseName = System.Configuration.ConfigurationManager.AppSettings["LICENSENAME"];

                    Header.licenseExpiration = System.Configuration.ConfigurationManager.AppSettings["LICENSEEXPIRATION"];

                    Header.siteKey = System.Configuration.ConfigurationManager.AppSettings["SITEKEY"];

                    Header.softwareName = "CTAPI";

                    myVendorsServiceValue = new ctDynamicsSL.vendorMaintenance.vendorMaintenance();

                    myVendorsServiceValue.ctDynamicsSLHeaderValue = Header;

                    myVendorsServiceValue.Timeout = System.Threading.Timeout.Infinite;

                }

                return myVendorsServiceValue;

            }

            set

            {

                myVendorsServiceValue = value;

            }

        }