Salut tout le monde,
J'ai fait un Web Service très simple (que j'ai eu sur le Web) qui retourne la chaîne "Hello World".
Voici son code :
Et je ne n'arrive pas à obtenir cette chaîne à partir de mon site Silverlight 2.0.
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 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Xml.Linq; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // [System.Web.Script.Services.ScriptService] public class Service : System.Web.Services.WebService { public Service () { //InitializeComponent(); } [WebMethod] public string HelloWorld() { return "Hello World"; } }
Voici le code :
Il n'y a plus d'erreurs de compliation mais "Hello World" ne s'affiche pas (quand je clique sur le bouton).
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 using Microsoft.Windows.Controls.DataVisualization.Charting; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.ServiceModel; using System; namespace MicrosoftVersion { public partial class Page : UserControl { public Page() { InitializeComponent(); PieSeries cs = TAR_PieChart.Series[0] as PieSeries; cs.ItemsSource = clsTAR_Datas.GetTAR_DataByStatus(); } private void CallServiceButton_Click(object sender, RoutedEventArgs e) { // using ASMX Web Service //ServiceTAR est le Web Service déclaré dans mon site Silverlight //MicrosoftVersion est l enom de mon site Silverlight ServiceTAR.ServiceSoapClient proxy = new MicrosoftVersion.ServiceTAR.ServiceSoapClient(); proxy.HelloWorldCompleted += new EventHandler(proxy_HelloWorldCompleted); proxy.HelloWorldAsync(); } void proxy_HelloWorldCompleted(object sender, MicrosoftVersion.ServiceTAR.HelloWorldCompletedEventArgs e) { string strlist = e.Result; //TextBoxEssai1 i sa textbox in my Silverlight page. TextBoxEssai1.Text = strlist; } } }
Mon navigateur me prévient juste que qu'il ya des erreurs en bas à gauche...
Qu'ai-je oublié ?
Merci beaucoup d'avance pour vos réponses.
Laurent.
Thank you very much for your answers.
Laurent.
Partager