Bonjour,

j'ai un WcfDataservice pointant sur un base de donnée Sql Server, tous deux hébergés sur Azure.

Je souhaiterais utiliser un client.

je ne peux pas ajouter la référence du service dans visual studio, car elle est sécurisée par Oauth.

du coup je fais ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
 static void Main(string[] args)
        {
 
            string token = GetTokenFromACS("http://*****.cloudapp.net/Acs***/");
            string serviceResponse = SendMessageToService(token);
 
            Console.WriteLine("Service responded with: {0}\n", serviceResponse);
            Console.WriteLine("Press  to exit");
            Console.ReadLine();
        }
        private static string SendMessageToService(string token)
        {
            WebClient client = new WebClient();
            client.BaseAddress = ConfigurationManager.AppSettings.Get("ServiceAddress");
            string headerValue = string.Format("WRAP access_token=\"{0}\"", token);
 
            client.Headers.Add("Authorization", headerValue);
 
            var serviceResponseBytes = client.DownloadString(String.Empty);
 
            return serviceResponseBytes;
        }
 
        private static string GetTokenFromACS(string scope)
        {
            string wrapPassword = ConfigurationManager.AppSettings.Get("WrapPassword");
            string wrapUsername = ConfigurationManager.AppSettings.Get("WrapUsername");
 
            // request a token from ACS
            WebClient client = new WebClient();
            client.BaseAddress = string.Format("https://{0}.{1}", accessControlNamespace, accessControlHostName);
 
            NameValueCollection values = new NameValueCollection();
            values.Add("wrap_name", wrapUsername);
            values.Add("wrap_password", wrapPassword);
            values.Add("wrap_scope", scope);
 
            byte[] responseBytes = client.UploadValues("WRAPv0.9/", "POST", values);
 
            string response = Encoding.UTF8.GetString(responseBytes);
 
            Console.WriteLine("\nreceived token from ACS: {0}\n", response);
 
            return HttpUtility.UrlDecode(
                response
                .Split('&')
                .Single(value => value.StartsWith("wrap_access_token=", StringComparison.OrdinalIgnoreCase))
                .Split('=')[1]);
 
        }
il me ramene donc le contenu Xml de l'objet Odata, mais j'aimerais le récupérer sous forme d'objet de mon entitymodel de mon Wcfdataservice...

à la limite je peux me debrouiller pour récuperer l'entitymodel autrement coté client en le regénérant, mais alors comment caster mon flux xml en mon objet Entity..?

Est-ce que quelqu'un aurait une solution s'il vous plait?

Merci d'avance!