VS2013 test by <Author: sword>
1. Create a new "silverlight applications" project;
2. Right-click the web project add "New Item Silverlight-enabled WCF Service";
3. Modify
public void DoWork() { return; }
for
public string SayHello(string userName) { return userName + ",hello world!!"; }
4. Build it;
5. Right-click the client project, adding "Service Reference" and found - "confirmation;
6.MainPage.xaml, add a textbox, a button and a label control;
7. Modify MainPage.xaml.cs, increase
private void button1_Click(object sender, RoutedEventArgs e) {
ServiceReference1.Service1Client myClient = new ServiceReference1.Service1Client();
myClient.SayHelloCompleted += mySayHelloCompleted;
myClient.SayHelloAsync(textbox1.Text);
}
void mySayHelloCompleted(object sender, ServiceReference1.SayHelloCompletedEventArgs e) { label1.Content = e.Result; }
8.Just run it!
Reproduced in: https: //www.cnblogs.com/aswordok/p/wcf.html