none
Incompatible WCF endpoints with W8 store app RRS feed

  • Question

  • I'm trying to build a Windows8 store app that consumes WCF services from an intranet site.

    I’ve been able to do this without any problems in a “normal” application on W8, it’s only when I try to develop it as a store app that I hit a brick wall. With the wall being that the app won’t compile as it’s coming back with an error stating that it’s unable to continue due to there being a compatibility with the endpoints of the service not being compatible with a store app. This is “fine” as it is a known issue because store apps only allow certain endpoints to be configured, as per http://msdn.microsoft.com/en-us/library/hh556233.aspx .

    So as our WCF service has incompatible endpoints, I’m unable to use the normal add service reference “wizard” to include the WCF “configuration” and thus what I need to do, effectively is the same as the add service reference using code at runtime and specifying the endpoint, and use BasicHTTPBinding as this will be compatible with our WCF service.

    I've looked just about everywhere that I can find and everywhere either shows you how to just create a WCF service, or it uses the add service reference wizard.

    From what I can gather the add service reference in VS2012 is only a "new(ish)" option, how was this configured prior?

    If someone has some code (full methods, classes, etc) that can show me how I can create a configuration to connect to a WCF client at run time it would be greatly appreciated as I'm about ready to call defeated on this one!!

    Tuesday, September 17, 2013 12:01 PM

Answers

  • The following thread describes how to consume a WCF service using a Metro app.  It seems like the service must be called asynchronously.

    http://stackoverflow.com/questions/9617042/any-sample-on-how-to-use-wcf-ria-services-in-xaml-metro-app

    Tuesday, September 17, 2013 5:04 PM
  • Hi,

    I am sorry that I misunderstand your idea.

    If you can not use the add service reference to call wcf service.

    Have you try to use the ChannelFactory? It should be like below:

    BasicHttpBinding myBinding = new BasicHttpBinding();
    	
    EndpointAddress myEndpoint = new EndpointAddress("http://localhost/MathService/Ep1");
    ChannelFactory<IService> myChannelFactory = new ChannelFactory<IService>(myBinding, myEndpoint);
    
    // Create a channel.
    IService wcfClient1 = myChannelFactory.CreateChannel();

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 24, 2013 6:15 AM
    Moderator

All replies

  • Hello-

      It seems like there is only one way to do this and it requires creating a DLL that contains all of the same methods, classes, etc. as the WCF service.  See this thread for more information:

    http://stackoverflow.com/questions/1193124/how-to-consume-wcf-web-service-through-url-at-run-time

    Tuesday, September 17, 2013 12:28 PM
  • Hi, thanks for the quick reply, but I've looked at trying to do this and the problem is that with Windows8 store apps there are restrictions on what can be used, references, dll's, etc. For example the proxy code generated for our WCF uses system.data - this is not available in W8 Store Apps as it has been removed by MSFT.

    There must be another way that this can be done?

    Tuesday, September 17, 2013 12:48 PM
  • The following thread describes how to consume a WCF service using a Metro app.  It seems like the service must be called asynchronously.

    http://stackoverflow.com/questions/9617042/any-sample-on-how-to-use-wcf-ria-services-in-xaml-metro-app

    Tuesday, September 17, 2013 5:04 PM
  • Hi,

    Yes, as you said there are some restrictions when call a wcf service from a Windows8 Store Apps.

    When call a WCF service from a Windows Store application, use the Add Service Reference feature of Visual Studio 2012. We will notice a few changes in the functionality of Add Service Reference when done within a Windows Store application. First no configuration file is generated. Windows Store applications do not use configuration files, so they must be configured in code. This configuration code can be found in the References.cs file generated by Add Service Reference. To see this file, make sure to select “Show All Files” in the solution explorer. The file will be located under the Service References and then Reference.svcmap nodes within the project. All operations generated for WCF services within a Windows Store application will be asynchronous using the Task-based asynchronous pattern.

    The following blogs all are about how to call a wcf service from a windows8 store apps by using the add service reference, please try to refer to:

    #Simple WCF Service in Windows Store Apps:
    http://www.c-sharpcorner.com/uploadfile/7e39ca/simple-wcf-service-in-windows-store-apps/ .

    #Consume Web Service in Windows Store App Using C#:
    http://codeprogs.wordpress.com/2013/03/22/183/ .

    #Consuming (calling) a WCF service in Windows store app:
    http://logicum.co/consuming-calling-a-wcf-service-in-windows-store-app/ .

    #Consuming WCF in Windows 8 Metro style app:
    http://bhrnjica.net/2011/09/26/consuming-wcf-in-windows-8-metro-style-app/ .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 18, 2013 1:59 AM
    Moderator
  • Yes, it needs to call the data asynchronously, however the problem I have is that I can't connect to the data using the add service reference wizard and need to code that part as a manual process at runtime.
    Wednesday, September 18, 2013 6:59 AM
  • Thanks, but you haven't read my initial question as I clearly state that I can't use the add service reference due to incompatible endpoints with the WCF service!
    Wednesday, September 18, 2013 7:00 AM
  • Hi,

    I am sorry that I misunderstand your idea.

    If you can not use the add service reference to call wcf service.

    Have you try to use the ChannelFactory? It should be like below:

    BasicHttpBinding myBinding = new BasicHttpBinding();
    	
    EndpointAddress myEndpoint = new EndpointAddress("http://localhost/MathService/Ep1");
    ChannelFactory<IService> myChannelFactory = new ChannelFactory<IService>(myBinding, myEndpoint);
    
    // Create a channel.
    IService wcfClient1 = myChannelFactory.CreateChannel();

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, September 24, 2013 6:15 AM
    Moderator