0

I have been contemplating on a dilemma for hours. I have a Visual Studio Solution that contains a WCF, WebForms, UWP, Xamarin and a SharedLibrary Projects. I intend to use the WCF project as the backend which talks to the database and process Email and SMS integration and feed the other apps.

OPTION A Currently, The WCF is hosted on an Azure App Service which makes it accessible via POST, GET, etc from the url which is: https://mywcfprojectlink.azurewebsites.net/service1.svc/GetUsers

With such arrangements, I can perform a POST request to get data from the apps:

 string response = string.Empty;
        string url = "https://mywcfprojectlink.azurewebsites.net/service1.svc/GetUsers";
        try
        {
            var values = new Dictionary<string, string>
            {
               { "data", Encryption.EncryptString(dat.ToString()) }  //dat is incoming method param
            };
            string jsonString = JsonConvert.SerializeObject(values);
            var cli = new WebClient();
            cli.Headers[HttpRequestHeader.ContentType] = "application/json";
            response = cli.UploadString($"{url}", jsonString);
            var result = JsonConvert.DeserializeObject<string>(response);
            topic.InnerText = Encryption.DecryptString(result.ToString());
        }
        catch (Exception)
        {
            return string.Empty;
        }

The method above is a simple one as I have other ones where I Deserialize with Models/Classes.

OPTION B I equally have access to the methods defined in service1 by adding the project reference to my WebForms which surprisingly is also compatible with xamarin but not with UWP. Nevertheless, I am interested in the WebForms scenario. Below is an example method:

using BackEnd;
        //Service1 service1 = new Service1();
        //var send = service1.GetUsers(dat.ToString()); //dat is incoming method param
        //topic.InnerText = send;

Obviously, using the Option B would eliminate the need to encrypt, decrypt, serialize or deserialize the data being sent. However, I have serious performance concerns. I need to know the better option and if there is yet another alternative (probably an Azure Resource), you can share with me.

Olorunfemi Davis
  • 1,001
  • 10
  • 23

1 Answers1

0

If you decide to use https endpoint of the Azure website, option A is secure because of SSL encryption. So you don't have to encrypt/decrypt it by yourself. The only tip is to create a proper authorization mechanism. For example use TransportWithMessageCredential. An example is provided in below article https://www.codeproject.com/Articles/1092557/WCF-Security-and-Authentication-in-Azure-WsHttpBin

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
  • The url i snow Https which azure provides. It's wonderful I do not have to Encrypt the information myself again. I am checking out the TransportWithMessageCredential – Olorunfemi Davis Mar 08 '18 at 09:42