So of late, I’ve been building lots of mobile applications that work by calling web-services. I’ve found myself time and time again passing the same parameters to each web-service function.
This was getting a bit boring, so I decided it was time to try and take the pain out of this repetitive process.
I’ve decided to now pass a standard class filled with useful parameters each time I make a web-service call.
So take the call to Login I now do the following -
lr = ra.Login(OURUSERID, Elements.BuildIn());
Now this doesn’t look that unusual, passing in the userid, we want to authenticate.
Elements.BuildIn(), is where all the action is at. This ensures we pass in a whole bunch of useful information and is as follows -
public static WSIn BuildIn()
{
WSIn ret = new WSIn();
ret.BluetoothOn = Elements.BlueToothEnabled;
ret.Company = Settings.Company;
ret.Printer = Settings.Printer;
ret.Profile = Core.AppSetting("profilename");
ret.SoftwareVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
ret.User = Globals.Instance.UserID;
ret.AppName = Core.AppSetting("AppName");
ret.Location = Settings.Location;
return ret;
}
I do this for each call, so we always get passed to the web-service that location of the user, their company , the software version, whether they are using a Bluetooth printer etc.
This saves a tonne of time.