Consumeing dynamic web services in a Metro App RRS feed

  • Question

  • Hi guys,

    First, let me start by saying C# is not my strong point, and neither is consuming web services. I have, however, inherited the development of a Metro App that needs to hook up to a web service and consume it.

    Normally, this isn't a problem, I can just right click on my project and click add service reference, which will generate everything for me. However, this app needs to work with different instances of an application on different servers all around the world.

    Another road block is that I cannot just change the endpoint address, as each instance of the application needs to be spun up before any sort of activity can be performed on it.

    Is there a way to dynamically create and add service references to my application at runtime? I've seen some solutions floating about, but none of them work with WinRT (as the assembly references in ".NET for Windows Store Apps" have been removed).

    Does anybody know if this is possible in a metro app?

    Thanks in advance!

    EDIT: Apologies, not all instances will need to be spun up. Still stuck for the ones that do!
    Wednesday, February 27, 2013 2:42 PM


  • Hi,

    Regarding: "Is there a way to dynamically create and add service references to my application at runtime?"

    For Windows Store apps, you need to add your service reference during development time, and not generate WCF proxy during runtime.

    If your requirement is to have such a functionality, you can setup a WebServer that acts like a proxy to the dynamic services (where the complete WCF functionality is available) and have your Windows Store apps talk to the proxy WebServer to perform the required operation and then relay the response information back to the Windows Store app. You can use HttpClient/XmlHttpRequest (depending on whether your app is C# or WinJS/C++ based) class from your Windows Store app to send a HTTP request to the proxy WebServer.

    Alternately, if you already know the format of the underlying HTTP request, you can create the HTTP request manually and then use the HttpClient/XmlHttpRequest class to send the request manually. This means that you have to perform the parsing of the response yourself.



    Wednesday, February 27, 2013 11:40 PM