Info |
---|
The account used to connect to your installation must have the the global permissions Web Services and Export Data permission enabled 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.
Attachments | ||
---|---|---|
|
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.
- Enter the WSDL address https://secure.projectorpsa.com/OpsProjectorWebSvc/OpsProjectorSvc.asmx?wsdl and click Go.
- Name the 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.
Tip | ||
---|---|---|
| ||
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. |
Code Block | ||
---|---|---|
| ||
using System; using System.Collections.Generic; using System.Linq; using System.WebText; using System.WebThreading.UITasks; using System.Web.UI.WebControlsServiceModel; using OldWebServicesGetResourceCount.ProjectorWebServicesV1; namespace WebApplication1OldWebServicesGetResourceCount { using Projector = com.projectorpsa.secure;class Program { public partial class index : System.Web.UI.Pagestatic void Main(string[] args) { Program program protected= voidnew Page_Load(object sender, EventArgs e)Program(); Console.WriteLine("Projector console {app running....\n"); //create an instance of the Projector Service Projector.OpsProjectorSvcvar svc = new Projector.OpsProjectorSvcOpsProjectorSvcSoapClient(); var header = new OpsAuthenticationHeader { SessionTicket = "XXXXXXXXXXXXXXXXXXXXXXXX", //Authenticate with server and ensure we have the correct Service URL svc.OpsAuthenticationHeaderValue = new Projector.OpsAuthenticationHeader();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 svc.OpsAuthenticationHeaderValue.//AccountName = "yourAccountName";, svc.OpsAuthenticationHeaderValue.//EmailAddress = "yourEmailAddress";, svc.OpsAuthenticationHeaderValue.//Password = "yourPassword" }; //Authenticate with server and ensure we have the correct Service URL Projector.GetWebServiceUrlRqvar gwsuRqgetWebServiceUrlRq = new Projector.GetWebServiceUrlRq(); Projector.GetWebServiceUrlRs gwsuRsgetWebServiceUrlRs = svc.GetWebServiceUrl(gwsuRqheader, getWebServiceUrlRq); if (gwsuRsgetWebServiceUrlRs.WebServiceUrl != null) { var svc.UrlnewEndpoint = string.Format("{0}/OpsProjectorWebSvc/OpsProjectorSvc.asmx", gwsuRs.WebServiceUrl)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 Projector.ExportResourcesRqvar erRqexportResourcesRq = new Projector.ExportResourcesRq();ExportResourcesRq { erRq.Parameters = new Projector.ExportResourcesRequest();ExportResourcesRequest { erRq.Parameters.OnlyCountRows = true } }; Projector.ExportResourcesRs erRsexportResourcesRs = svc.ExportResources(erRqheader, exportResourcesRq); int iResources = erRsexportResourcesRs.Data.RowCount; Console.WriteLine("Your installation has " + iResources.ToString() + " active resources as of today.\n"); Console.WriteLine("Press enter to quit"); Console.ReadLine(); } } } |