locked
[wp8.1] how to consume web service? RRS feed

  • Question

  • Hi

     How to consume web service?

    I checked the Consume Web service .But "add service reference" is not available in My VS 2015.

    How can i consume web service for my windows phone8.1 app?

    Thursday, February 25, 2016 7:38 AM

Answers

  • WCF Add Service Reference is not supported for Windows Phone 8.1 Runtime apps.

    If you can expose a REST endpoint from your service then you can connect to it with the HttpClient class.

    If you can upgrade to Windows 10 Mobile then Add Service Reference is supported for Universal Windows Platform apps.

    • Proposed as answer by Xavier Xie-MSFT Wednesday, March 2, 2016 7:55 AM
    • Marked as answer by Barry Wang Monday, March 7, 2016 9:31 AM
    Friday, February 26, 2016 4:57 AM

All replies

  • did you click the right project? go to your project, find references, right click on it, and you will see add service reference

    
    Thursday, February 25, 2016 4:37 PM
  • Assuming the Web service is already created, to consume it, you need to add the web service reference in your Visual Studio. Follow this link to add the reference:

    https://msdn.microsoft.com/en-us/library/bb628649(v=vs.120).aspx

    Once done, lets assume that the Service Reference name was given as LocalhostWebService, from code try the following to instantiate the service:

    LocalhostWebService.Service1 reference = new LocalhostWebService().Service1();

    populate the reference object by reference.<PropertyName> = <PropertyValue>;

    Call reference.<MethodName> passing the input parameters and store the response in response object.

    Use the response object to get the service outcome.


    Thanks, AT

    Thursday, February 25, 2016 4:57 PM
  • WCF Add Service Reference is not supported for Windows Phone 8.1 Runtime apps.

    If you can expose a REST endpoint from your service then you can connect to it with the HttpClient class.

    If you can upgrade to Windows 10 Mobile then Add Service Reference is supported for Universal Windows Platform apps.

    • Proposed as answer by Xavier Xie-MSFT Wednesday, March 2, 2016 7:55 AM
    • Marked as answer by Barry Wang Monday, March 7, 2016 9:31 AM
    Friday, February 26, 2016 4:57 AM
  • Hi Rob Caplan,

        what is mean by "expose a REST endpoint from my service"?

    Whether back-end team who provide web service for me have to do that?

    Friday, February 26, 2016 5:16 AM
  • Yes. The web service provider would need to change that on the server.
    Friday, February 26, 2016 8:24 PM
  • Hi

          If web service provider didn't  change that on the server ,then what is the way for me to consume web service?

    Friday, April 1, 2016 10:23 AM