Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Telerik
Hi all,
I developed a wcf service by using windows Azure Cloud service.
Now i need to call that wcf service into my application. I am using Rad center windows phone application. I added wcf service in service reference but not possible to create
a reference in page1.xaml.cs . any suggestions appreciate.
 
Note: I already goggled i got below link but not useful to my concept.
 

thanks in advance.
nareshraju
Posted 21-Jun-12 19:47pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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)
{
    // Instantiate a web service client
    // Note that the name MyWebService gets the word Client appended
    MyServiceReference.MyWebServiceClient proxy = new MyServiceReference.MyWebServiceClient();
    // Create a handler for the webservice - note it has the word Completed on the end of the web service operation included 
    proxy.Get42Completed += new
        EventHandler<MyServiceReference.Get42CompletedEventArgs>
        (GetDataCompleted);
    // Make the call to the webservice, note it has the word Async appended
    proxy.Get42Async();
}
 
void Get42Completed(object sender,
    MyServiceReference.Get42CompletedEventArgs e)
{
    // Always check for errors before examining the result
    if(e.Error != null)
    {
        MessageBox.Show(e.Error.ToString());
        return;
    }
    // Read the result
    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.
  Permalink  
v3
Comments
Sandeep Mewara at 24-Jun-12 4:37am
   
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 BillWoodruff 205
2 Maciej Los 205
3 DamithSL 165
4 Sergey Alexandrovich Kryukov 145
0 OriginalGriff 5,107
1 DamithSL 4,157
2 Maciej Los 3,595
3 Kornfeld Eliyahu Peter 3,450
4 Sergey Alexandrovich Kryukov 2,741


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 23 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100