I am trying to write a console application using C # 2.0 that will consume my web service and return the results from the web method.
In my C # code, I can get my values from the web method, see below code example:
try
{
Type objtype = Type.GetType(crisresult.ToString());
object obj = Activator.CreateInstance(objtype);
Object[] mArgs = new Object[methodArgs.Length + 1];
methodArgs.CopyTo(mArgs, 0);
mArgs.SetValue(obj, methodArgs.Length);
methodArgs = mArgs;
Object result = mi.Invoke(service, methodArgs);
Console.WriteLine(result);
}
catch (Exception e)
{
Console.WriteLine("Error invoking method '" + methodName + "'");
Console.WriteLine(e);
}
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
Now in the above code, my results from my web method are perfectly valid in JSON Type, so mine Object result
has JSON type values, for example:
{"FullName":"Mr Mahesh Sharma","Miles":0,"TierStatus":"IO","TierMiles":0,"MilesExpiry":0,"ExpiryDate":"30/03/2012 00:00:00","AccessToken":"106C9FD143AFA6198A9EBDC8B9CC0FB2CE867356222D21D45B16BEEB9A7F390B5E226665851D6DB9","ActiveCardNo":"00300452124","PersonID":8654110}
The above result, I want to print on the console with the following format:
FullName: Mr Mahesh Sharma
Miles: 0
TierStatus: IO
TierMiles:0
MilesExpiry:0
ExpiryDate:31 March 2012
AccessToken: 106C9FD143AFA6198A9EBDC8B9CC0FB2CE867356222D21D45B16BEEB9A7F390B5E226665851D6DB9
ActiveCardNo: 00300452124
PersonID: 8654110
source
share