Forms web service
For the next few posts, I plan to write up a few small examples of code using the Groove Forms web service.
There's a sample, GrooveFormsExplorer, in the development kit, which shows how to read Groove accounts, identities, workspaces and tools; and how to read data from a Groove Forms tool into a DataSet. But this sample doesn't cover inserting or updating records; nor how to use file attachments.
So, let's begin near the beginning. Assume that this application has web references to GrooveToolsWebService and GrooveForms2WebService. There's also a helper class GWSUtil which knows how to read registry settings for the various header keys and such.
I'll start with a class to wrap access to the Forms tool; its constructor takes a Tool:
public class GrvFormsTool
{
private
string _identityURL;
private
GrooveToolsWebService.Tool _tool;
public GrvFormsTool(GrooveToolsWebService.Tool t, string identityURL)
{
_tool = t;
_identityURL = identityURL;
}
}
For each call to the Forms tool's data service, we need an instance of the web service proxy, with the various parameters in place. So here's a little helper method to get that:
private GrooveForms2WebService.GrooveForms2 GetDataService()
{
GrooveForms2WebService.GrooveForms2 svc = new GrooveForms2WebService.GrooveForms2();
svc.GrooveRequestHeaderValue = new GrooveForms2WebService.GrooveRequestHeader();
svc.GrooveRequestHeaderValue.GrooveRequestKey = GWSUtil.GrooveLocalRequestKey;
svc.GrooveRequestHeaderValue.GrooveIdentityURL = _identityURL;
svc.Url = GWSUtil.GrooveURL + _tool.Data;
return svc;
}
Forms tools begin life in an "un-initialized" state, where no fields and forms have been defined. These uninitialized tools aren't very useful; in fact, if you try to read their data, you'll get an error. So before each call to the web service, we should check that the design is initialized already. Of course there's no need to check this for every call, just once.
private
bool _isDesignInitialized = false;
public
bool IsDesignInitialized
{
get
{
if (_isDesignInitialized)
{
return true;
}
// Construct and initialize an instance of the web service proxy
GrooveForms2WebService.GrooveForms2 svc = GetDataService();
_isDesignInitialized = svc.IsFormsToolDesignInitialized();
return _isDesignInitialized;
}
}
OK. Let's pause here for now; this code should compile, but I need to clean up the formatting to make it look good as a blog post.