You'll find information on passing credentials to a CS Web Service in Community Server Forums and elsewhere on the net, including this post written just a few days ago--in Romanian. Cool! But it's useful info and yet another example of CS's smart design.
A ServiceCredentials : SoapHeader class resides in the CS.Components.CSWebServiceBase class, from which all Community Service Web Services derive. It looks like so.
public abstract class CSWebServiceBase : WebService
{
public CSWebServiceBase()
{
}
public class ServiceCredentials : SoapHeader {
public string Username;
public string Password;
public string SectionName;
}
Each exposed Web Service Method begins by evoking a Login() method, also located in CSWebServiceBase, which validates the user's credentials against CS and that SectionName, or ApplicationKey.
Passing that info from the client looks something like the following, which I encapsulate in its own method. And yes, since I'm ultimately writing a Live Writer Plugin, the logic of how I'm retrieving the data will change, but not the logic of passing the credentials to the Community Server Web Service.
public dbvtcs21.DBVTGalleryService wsGalleryService()
{
dbvtcs21.DBVTGalleryService gs = new CSMultiImageWindows.dbvtcs21.DBVTGalleryService();
dbvtcs21.ServiceCredentials cred = new dbvtcs21.ServiceCredentials();
System.Configuration.AppSettingsReader appReader = new System.Configuration.AppSettingsReader();
cred.Username = (string)appReader.GetValue("Username", typeof(string));
cred.Password = (string)appReader.GetValue("Password", typeof(string));
cred.SectionName = (string)appReader.GetValue("Gallery", typeof(string));
gs.ServiceCredentialsValue = cred;
return gs;
}
Instantiating the Web Service from the client to, say, retrieve a photo gallery albums[] array then becomes
CSMultiImageWindows.dbvtcs21.Album[] albums = wsGalleryService().GetAlbumHeirarchy();
And then can have fun with the Album information, in this case use it to populate the dropdown list.