/
Examples

Examples

The account used to connect to your installation must have the global permissions Web Services and Export Data enabled.

C#

This example will retrieve the number of resources in your installation. 

Project

This example was tested with Visual Studio 2013. The project is a console application. You can download a VS2013 example project here.

  File Modified

ZIP Archive OldWebServicesGetResourceCount.zip

Dec 24, 2014 by Thomas Sherman

Add Web Reference

You'll need to add a web reference to Projector's WSDL. You can do so by right-clicking References in the solution explorer and choosing Add Service Reference.

Add Using Reference

Using the name of your project and the name of your web service, add a using directive to the top of your program. In the example below, my project is OldWebServicesGetResourceCount. The service reference is called ProjectorWebServicesV1.

Code Example

Using the below code as a starting place, start using our web services.

Session Tickets

This example assumes that you can create a session ticket. To learn how to create session tickets see C Sharp Example. You must use the v2 web services to generate session tickets. They can be used by the v1 services going forward though.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using OldWebServicesGetResourceCount.ProjectorWebServicesV1;
 
namespace OldWebServicesGetResourceCount
{
    class Program
    {
        static void Main(string[] args)
        {
            Program program = new Program();
            Console.WriteLine("Projector console app running....\n");
            //create an instance of the Projector Service
            var svc = new OpsProjectorSvcSoapClient();
            var header = new OpsAuthenticationHeader
            {
                SessionTicket = "XXXXXXXXXXXXXXXXXXXXXXXX",
                //you can log in using your credentials directly, but we strongly discourage this approach. You should generate session tickets to log in. Direct credentials are fine for some simple tests
                //AccountName = "yourAccountName",
                //EmailAddress = "yourEmailAddress",
                //Password = "yourPassword"
            };
            //Authenticate with server and ensure we have the correct Service URL
            var getWebServiceUrlRq = new GetWebServiceUrlRq();
            GetWebServiceUrlRs getWebServiceUrlRs = svc.GetWebServiceUrl(header, getWebServiceUrlRq);
            if (getWebServiceUrlRs.WebServiceUrl != null)
            {
                var newEndpoint = string.Format("{0}/OpsProjectorWebSvc/OpsProjectorSvc.asmx", getWebServiceUrlRs.WebServiceUrl);
                Console.WriteLine("Redirecting your endpoint to: \n" + newEndpoint + "\n");
                svc = new OpsProjectorSvcSoapClient(new BasicHttpsBinding(), new EndpointAddress(newEndpoint));
            }
            //Retrieve some data from the installation using Rq/Rs
            var exportResourcesRq = new ExportResourcesRq
            {
                Parameters = new ExportResourcesRequest
                {
                    OnlyCountRows = true
                }
            };
            ExportResourcesRs exportResourcesRs = svc.ExportResources(header, exportResourcesRq);
            int iResources = exportResourcesRs.Data.RowCount;
            Console.WriteLine("Your installation has " + iResources.ToString() + " active resources as of today.\n");
            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
    }
}

Related content

Getting Started with Web Services 2.0
Getting Started with Web Services 2.0
More like this
OAuth 2.0 Client Application Developer Guide
OAuth 2.0 Client Application Developer Guide
Read with this
GetWebServiceUrl
GetWebServiceUrl
More like this
SubmitReportSpec
SubmitReportSpec
Read with this
Getting Started with Web Services
Getting Started with Web Services
More like this
Report Web Services
Report Web Services
Read with this