Knowledge Base Article

Home Page > Knowledge Base > Spira Platform

Home Page > Knowledge Base > Spira Platform > SpiraPlan

Home Page > Knowledge Base > Spira Platform > SpiraTeam

Home Page > Knowledge Base > Spira Platform > SpiraTest

Article How to access Spira v3.x SOAP web services using C#

by Adam S on Thursday, July 5, 2012

This knowledge base article describes how to connect to the SpiraTest, SpiraPlan & SpiraTeam SOAP web services using .NET code written in C#. The code assumes that you're using Visual Studio 2008 or later and are using the newer .NET 3.0+ Windows Communication Foundation (WCF) "Add Service Reference" rather than the older .NET 2.0 ASMX web service client.

The following code will connect to Spira, authenticate, connect to a project and then get a list of incidents fixed in a specific release:

   //Instantiate the web-service proxy class and set the URL from the .config file
   
spiraImportExport = new TestSuite.SpiraImportExport30.ImportExportClient();
   spiraImportExport.Endpoint.Address = new EndpointAddress("http://servername/SpiraTest/Services/v3_0/ImportExport.svc");

   //Configure the HTTP Binding to handle session cookies
   BasicHttpBinding httpBinding = (BasicHttpBinding)spiraImportExport.Endpoint.Binding;
   httpBinding.AllowCookies = true;
   httpBinding.Security.Mode = BasicHttpSecurityMode.None;

   //Next lets authenticate and connect to the project
   int projectId = 1;
   spiraImportExport.Connection_Authenticate("username", "password");
   spiraImportExport.Connection_ConnectToProject(projectId);

   //Now lets get a list of incidents fixed in Release RL00005
   int releaseId = 5;
   List<RemoteFilter> remoteFilters = new List<RemoteFilter>();
   RemoteFilter remoteFilter = new RemoteFilter();
   remoteFilter.PropertyName = "ResolvedReleaseId";
   remoteFilter.IntValue = releaseId;
   remoteFilters.Add(remoteFilter);
   RemoteSort remoteSort = new RemoteSort();
   remoteSort.PropertyName = "Name";
   remoteSort.SortAscending = true;
   List<RemoteIncident> remoteIncidents = spiraImportExport.Incident_Retrieve(remoteFilters.ToArray(), remoteSort, 1, 999999);

   //Loop through and display ID, name and description
   foreach (RemoteIncident remoteIncident in remoteIncidents)
   {
       Response.Write(remoteIncident.IncidentId);
       Response.Write(remoteIncident.Name);
       Response.Write(remoteIncident.Description);
   }

Attachments
Article Info
Last Updated: 7/5/2012
Article ID: KB3
# Views: 4482
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.