Bonjour
je désire consommer un flux xml qui est fournis via une API que j'ai réalisé en php avec le framwork symfony en utilisant un serveur apache qui tourne localement via le port 8181.
voici le flux en question :
Et voici le bout de code c# (windows phone 8)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <Livres> <Livre id="0"> <Titre> Newport Beach. [Episodes 9-12] : [Saison 2] / Michael Fresco, Tony Wharmby, Ian Toynton, réal ; Josh Schwartz, concept., scénario ; J.J. Philbin, Drew Z. Greenberg, Allan Heinberg, scénario ; Christopher Tyng, mus ; Peter Gallagher, Kelly Rowan, Ben McKenzie... [et al.], act </Titre> </Livre> <Livre id="1"> <Titre> Newport Beach. [Episodes 17-20] : [Saison 2] / Michael Lange, Norman Buckley, Tony Wharmby, réal ; Josh Schwartz, concept., scénario ; J.J.Philbin, Cory Martin, John Stephens... [et al.], scénario ; Christopher Tyng, mus ; Peter Gallagher, Kelly Rowan, Ben McKenzie... [et al.], act </Titre> </Livre> <Livres>
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
52
53
54
55 public void GetBooks(string auteur, string titre){ try { UriBuilder uriRechercheParTitreEtAuteur = new UriBuilder("http://localhost:8181/frontend_dev.php/api/a/newport/book.xml"); //Marche en utilisant ce flux //UriBuilder uriRechercheParTitreEtAuteur = new UriBuilder("http://forecast.weather.gov/MapClick.php"); //uriRechercheParTitreEtAuteur.Query = "lat=47.67&lon=-122.12&FcstType=dwml"; HttpWebRequest bookRequest = (HttpWebRequest)WebRequest.Create(uriRechercheParTitreEtAuteur.Uri); BookUpdateState bookState = new BookUpdateState(); bookState.AsyncRequest = bookRequest; bookRequest.BeginGetResponse(new AsyncCallback(HandleBookResponse), bookState); } catch (WebException e) { System.Diagnostics.Debug.WriteLine("\r\nWebException Raised. The following error occured : {0}", e.Message); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("\nThe following Exception was raised : {0}", e.Message); } } private void HandleBookResponse(IAsyncResult asyncResult) { try { BookUpdateState bookState = (BookUpdateState)asyncResult.AsyncState; HttpWebRequest bookRequest = (HttpWebRequest)bookState.AsyncRequest; bookState.AsyncResponse = (HttpWebResponse)bookRequest.EndGetResponse(asyncResult); Stream streamResult; streamResult = bookState.AsyncResponse.GetResponseStream(); //....ETC } catch (WebException e) { HttpWebResponse rep = (HttpWebResponse)e.Response; System.Diagnostics.Debug.WriteLine("Erreur : {0} ",rep.StatusCode); System.Diagnostics.Debug.WriteLine("\r\nWebException Raised. The following error occured : {0}", e.Status); } catch (Exception e) { System.Diagnostics.Debug.WriteLine("\nThe following Exception was raised : {0}", e.Message); } }
en testant le flux sous chrome et firefoxe ça marche nickel mais bug sous i.e. j'ai testé un flux externe qui marche bien. donc ma conclusion est que le programme c# marche, c'est le format du flux qui cloche.
y'a t-il un paramétrage précis sur apache ou alors sur l'encodage u flux de retour ?
Merci de vos conseils![]()
Partager