If you've successfully created a service reference in the same project as that code, then it shouldn't be too hard to code it. Getting your config file correct is fiddly, but the code probably goes something like this:
Say my Service Reference is called
MyServiceReference
and the web service itself is called
MyWebService
. We'll say that you have a method called
Get42
which returns the number 42 as an int.
public Page1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Page1_Loaded);
}
void Page1_Loaded(object sender, RoutedEventArgs e)
{
MyServiceReference.MyWebServiceClient proxy = new MyServiceReference.MyWebServiceClient();
proxy.Get42Completed += new
EventHandler<MyServiceReference.Get42CompletedEventArgs>
(GetDataCompleted);
proxy.Get42Async();
}
void Get42Completed(object sender,
MyServiceReference.Get42CompletedEventArgs e)
{
if(e.Error != null)
{
MessageBox.Show(e.Error.ToString());
return;
}
MessageBox.Show(e.Result.ToString());
}
Here are a few things to watch out for...
Your service reference should be set to allow Async calls, so right click it, and choose "Configure service reference" and check that. Also check that your web service hasn't got its operations marked as static as that makes them invisible to the client.
Hope that helps.
Please mark as the answer if this answers your question.