1

If you create a new project, WCF Service Application C#, it makes a web service and starts it up.

But there is no information on how to actually communicate with it from a client, or how to even write that.

What does the UWP client look like which will communicate with that service?

TheBard
  • 156
  • 1
  • 11
  • 1
    See [this answer](http://stackoverflow.com/a/1193135/1136211). – Clemens Apr 14 '16 at 20:16
  • That's not what I mean. An example of a UWP that can call that GetData function. I don't get anything to work. I can't even manually get an answer by typing in the browser with their service running. – TheBard Apr 14 '16 at 20:51
  • That answer should get you going in the right direction. In short, you need to create a client that can call the web service. The way to do that is outlined in the answer Clemens linked to. – Tim Apr 14 '16 at 21:14
  • Nope. The question is perfectly clear. Write an endpoint to the Microsoft default project. No links. Post your code. – TheBard Apr 15 '16 at 12:16
  • @jockey4her - It doesn't seem clear to me. The functionality for accessing a SOAP web service (WCF) is the same whether you're doing it from a console app, a WinForms, Web Forms or UWP or whatever. That's the whole idea behind web services - interoperability. – Tim Apr 15 '16 at 15:29

1 Answers1

1

How to make a UWP that will work with the default WCF Service application

  1. Create a default WCF Service application and start it up as you have already did.

  2. Create a Universal Windows Blank App by following Create a "Hello, world" app (XAML) in the same solution.

  3. Add service reference for your universal app enter image description here
  4. Click Discover, it will default find the wcf service in your solution.Change the namespace to meet your requirement.enter image description here
  5. Add following code to a button click event handle.Then run uwp you will see the GetData Result.

    private async void BtnConnectWcf_Click(object sender, RoutedEventArgs e)
    {
        ToDoService.Service1Client client = new ToDoService.Service1Client();       
        await new Windows.UI.Popups.MessageDialog(client.GetDataAsync(10).Result.ToString()).ShowAsync();
        await client.CloseAsync();
    }
    

    enter image description here

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
  • Thanks, I got this to work, but it was not very clear. Add Service Reference menu does not appear like in your picture. I happen to stumble on it by accident, by clicking not the Solution, but the project, then Add, then found it down further in the list. After that this answer works. – TheBard May 16 '16 at 20:51