Reputation: 580
I am new to silverlight, just wanted know if the steps involved in calling the WCF service same in Silverlight as it was in asp or is there any difference.If there is any difference then request you to help me out.
Thanks in advance.
Upvotes: 1
Views: 167
Reputation: 580
I got the answer, there is slight difference between asp and silverlight. In silverlight all service calls are asynchronous, so you have to have an eventhandler for when the async call is completed you get your data.
Just a small e.g
When you call your WCF service from asp, you use
proxy_http.FunctionClient fc = new proxy_http.FunctionClient();
txtDisplay.Text = fc.Add(Convert.ToInt32(txtFirst.Text),Convert.ToInt32(txtSecond.Text)).ToString();
in case of Silverlight you will use
private void Add_Click(object sender, RoutedEventArgs e)
{
proxy_htt.FunctionClient fc = new proxy_htt.FunctionClient();
fc.AddCompleted += new EventHandler<proxy_htt.AddCompletedEventArgs>(fc_AddCompleted);
fc.AddAsync(Convert.ToInt32(txtFirst.Text),Convert.ToInt32(txtSecond.Text));
}
void fc_AddCompleted(object sender, proxy_htt.AddCompletedEventArgs e)
{
txtResult.Text = e.Result.ToString();
}
Upvotes: 1
Reputation: 5874
The main things that you needs aware are
http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx
Upvotes: 1