1
Answer

Consuming Rest Service in Xamarin Android Development

Robin Simon

Robin Simon

8y
287
1
I have created a REST service with a method getPatientDetails which takes in a parameter and return  a dataset.
 
 I have deployed this REST service  in IIS and URL is http://172.24.4.85/IMAO_REST_Service/PatientService.svc/getPatientDetails/28135635967
 
I need to consume this method in android button click event .
 
I am really very new to android development.
 
Can please someone help me to access this  
 
NOTE: i have used VS 2015 for creating REST Service and same VS 2015 for Android Development 
Answers (1)
1
Marjan Venema

Marjan Venema

NA 56 0 9y
Ah, hmm, then you are in a bit of a pickle. That is much harder.

You could try replacing any {0} (and {1}, {2}) with some RegEx and then trying to match the string you get at run time against that.

For example:

        Boolean AreEqual(string template, string text)
        {
            string regexed = template.Replace("{0}", ".*");
            regexed = template.Replace("{1}", ".*");
            regexed = template.Replace("{2}", ".*");

            Regex regex = new Regex(regexed);
            return regex.IsMatch(text);

        }

Please note, my RegEx skills are below par. And of course you would want to replace the replacements at the top with something more intelligent.

Cheers, Marjan
Accepted
1
Marjan Venema

Marjan Venema

NA 56 0 9y
If you have the value(s) of the arguments at runtime as well, then you could do something like: 

        Boolean Matches(string runTimeFullString, string runTimeArgument)
        {
            string FromDatabase = "The Cow is {0}";
            return runTimeFullString.Equals(string.Format(FromDatabase, runTimeArgument));
        }

If that doesn't help, could you please clarify what you are trying to achieve and what pieces of information you have to work with?
0
Murugesh P

Murugesh P

NA 179 5.7k 9y
Hi Marjan, Thanks for your response. Basically i have to compare two strings one from Resource file another from Databse. Ex: In Resource: The cow is {0} In Data Base: The cow is {0} But during run time the Parameter {0} will be filled and it becomes "The cow is white". So comparing The cow is {0} and The cow is White will be marked as difference. And Data base will not have run time parameters. So Basically i need to compare the strings without the Parameter {0}.
0
Abhineet Srivastava

Abhineet Srivastava

NA 1.1k 62.7k 9y
String.compare(s1,s2)
0
Suthish Nair

Suthish Nair

NA 31.7k 4.6m 9y
using String.Compare method.