I have a simple service with a single operational contract method called Sum
[OperationContact]
int sum(int i, int q);
When I am integrating the web service into a Silverlight app, adding this code into the main page:
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
it doesn't call sum method. Moreover it shows:
obj.sumAsync(int i, int q)
Silverlight doesn't allow creation of a sync proxy of Web Services. It uses an async service proxy model. There will be two properties for each OperationContract in Silverlight:
obj.sumAsync(int i, int q, object state)
obj.sumAsyncCompleted; // Event
You should try this:
private void CallMethod()
{
obj.sumAsync(2,2);
obj.sumAsyncCompleted += (s,e) =>
{
if (e.Error == null)
{
MessageBox.Show(e.Result.ToString());
}
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With