1

I am trying to migrate my code from normal wpf application to Universal Windows Platform. Previously I have used VS 2012 for Developing my WPF application And its working fine. Now I want to use the same application for mobile also.I found UWP as a solution for it. Now I am using vs 2015 . But here in vs 2015 I am unable to find Web Reference Option I am able to see only Service Reference. Actually My situation is I am Dynamically taking Ip Address and port number from User Based on the request I am connecting to that particular services like

public const string GET_SKU_DETAILS = "http://{0}:{1}/OmniRetailerServices/SkuServices/getSkuDetails?skuID={2}";

So like this I am connecting to particular Remote servers for accessing services.

And I did this using Web References in vs 2012. But Here in vs 2015 I am not able to find Web Reference. So My Question is How can I do this in UWP application Using VS 2015.

Please Help me to solve this Issue.

Thanks In Advance.

Sagar
  • 371
  • 9
  • 26

3 Answers3

2

Yes you can. Just proceed as if you gonna add a new service reference (Yes I now that you need to add a web reference) then on the bottom left of the "Add Service Reference" window, click on "Advanced" option. Then, again on the bottom, you see "Compatibility" and near the "Add Web Reference" button, now got it! :)

1

Web references (ASMX web service clients) are considered as legacy even in classic desktop applications, such as WPF. Service references (WCF service clients) are their successor and as you already noticed, they are available in UWP apps.

Just create a service reference instead of a web reference. You should be able to create it by pointing at the same WSDL as you did to create a web reference.

You can change the endpoint URL when creating an instance of the client proxy:

// use the base URL without the method name
var url = String.Format("http://{0}:{1}/OmniRetailerServices/SkuServices", hostname, port);

var client = new SkuServicesClient(new BasicHttpBinding(), new EndpointAddress(url));

To invoke the web method, call the corresponding method on the generated proxy:

var result = await client.GetSkuDetailsAsync(argument);

Not knowing the details about your service, I tried to come up with reasonable URL value and names in my code to match the info you have provided. It should be enough to get you going even if they won't be identical in your case.

Damir Arh
  • 17,637
  • 2
  • 45
  • 83
0

you can't do this. you need to find another way like HttpClient.

HttpClient is the easy way to consume web services.

https://blogs.windows.com/buildingapps/2015/11/23/demystifying-httpclient-apis-in-the-universal-windows-platform/

RicardoPons
  • 1,323
  • 9
  • 14