Obtaining Information From Cicero
Now that we have obtained a token from Cicero, we are now ready to use the service to obtain information. We will now demonstrate how to discover the local (city level) district ID of an address and output e-mail addresses of officials that represent that district.
Starting with our basic console application, we now need to add two more Cicero services as webreferences - the Geocoding Service and the Elected Official Query Service. Using the "Add Webreference..." dialog box viewable by right clicking on your console project, add references to the following two URLs: "http://cicero.avencia.com/avencia.Cicero.WebService.v2/GeocodingService.asmx" and "http://cicero.avencia.com/avencia.Cicero.WebService.v2/ElectedOfficialQueryService.asmx". Name them "GeocodingService" and "ElectedOfficialService" respectively.

Once the references have been added we add on to our original program as follows:
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string username = "YourName@YourCompany.com";
string password = "YourPass";
AuthenticationService.AuthenticationService auth;
auth = new AuthenticationService.AuthenticationService();
string token = auth.GetToken(username, password);
Console.WriteLine("Token is: " token);
//Get DistrictInfo
GeocodingService.GeocodingService gSvc;
gSvc = new GeocodingService.GeocodingService();
//Since its possible for an address to geocode to several different locations,
//GetDistrictsByAddress returns an array of DistrictInfo Objects
GeocodingService.Location[] locs =
gSvc.GetDistrictsByAddress(token, "1234 Market St.",
"Philadelphia", "PA", "", "US", "LOCAL");
//The best geocode is returned first. We will use that location.
if (locs.Length > 0)
{
//It is possible for a single location to return multiple districts
//But this usually not the case. We will only use the first district here.
Console.WriteLine("DistrictID: " locs[0].Districts[0].DistrictID);
//Use the DistrictID to get the elected officials and their e-mail
ElectedOfficialService.ElectedOfficialQueryService eSvc =
new ElectedOfficialService.ElectedOfficialQueryService();
ElectedOfficialService.ElectedOfficialInfo[] eoInfos;
eoInfos = eSvc.GetOfficialsByDistrictIDList(token,
locs[0].Districts[0].DistrictID, "Philadelphia", "PA", "US", "LOCAL", false);
foreach (ElectedOfficialService.ElectedOfficialInfo eoi in eoInfos)
{
Console.WriteLine("Representative: "
eoi.LastName ", "
eoi.FirstName ": "
eoi.EMail1);
}
}
else
{
Console.WriteLine("No District Found!");
}
Console.ReadKey();
}
}
}
The program output is as follows:
