Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info

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. 

...

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.

Enter the WSDL address and name https://secure.projectorpsa.com/OpsProjectorWebSvc/OpsProjectorSvc.asmx?wsdl and click Go.

Name the reference.

 

Image RemovedImage Added

 

Once the reference is added, the following code should execute (with proper authentication information):

 

 using
Code Block
languagecsharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using ProjectorExampleWS1OldWebServicesGetResourceCount.ServiceReference1ProjectorWebServicesV1;
namespace ProjectorExampleWS1OldWebServicesGetResourceCount
{
	    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
			{
				            {
                AccountName = "youraccountyourAccountName",
				
                EmailAddress = "youremailyourEmailAddress",
				
                Password = "yourpasswordyourPassword"
			};
			
            };
            //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)
			{
				svc.Endpoint.Address = new EndpointAddress(
            {
                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();
        }
    }
}