• Blog
  • Info Support
  • Career
  • Training
  • International Group
  • Info Support
  • Blog
  • Career
  • Training
  • International Group
  • Search
logo InfoSupport
  • Latest blogs
  • Popular blogs
  • Experts
      • Alles
      • Bloggers
      • Speakers
  • Meet us
  • About us
    • nl
    • en
    • .NET
    • Advanced Analytics
    • Agile
    • Akka
    • Alexa
    • Algorithms
    • Api's
    • Architectuur
    • Artificial Intelligence
    • ATDD
    • Augmented Reality
    • AWS
    • Azure
    • Big Data
    • Blockchain
    • Business Intelligence
    • Cloud
    • Code Combat
    • Cognitive Services
    • Communicatie
    • Containers
    • Continuous Delivery
    • CQRS
    • Cyber Security
    • Dapr
    • Data
    • Data & Analystics
    • Data Science
    • Data Warehousing
    • Databricks
    • DevOps
    • Digital Days
    • Docker
    • eHealth
    • Enterprise Architecture
    • Hacking
    • Infrastructure & Hosting
    • Innovatie
    • Integration
    • Internet of Things
    • Java
    • Machine Learning
    • Microservices
    • Microsoft
    • Microsoft Bot Framework
    • Microsoft Data Platform
    • Mobile Development
    • Mutation Testing
    • Open source
    • Pepper
    • Power BI
    • Privacy & Ethiek
    • Python
    • Quality Assistance & Test
    • Quality Assurance & Test
    • Requirements Management
    • Scala
    • Scratch
    • Security
    • SharePoint
    • Software Architecture
    • Software development
    • Software Factory
    • SQL Server
    • SSL
    • Start-up
    • Startup thinking
    • Stryker
    • Test Quality
    • Testing
    • TLS
    • TypeScript
    • Various
    • Web Development
    • Web-scale IT
    • Xamarin
    • Alles
    • Bloggers
    • Speakers
Home » How to enable LightSwitch as backend for your WP7 App
  • How to enable LightSwitch as backend for your WP7 App

    • By Marcel de Vries
    • .NET 11 years ago
    • .NET 0 comments
    • .NET .NET
    How to enable LightSwitch as backend for your WP7 App

    *Moved to: http://fluentbytes.com/how-to-enable-lightswitch-as-backend-for-your-wp7-app/

    I have been asked to work with my two colleagues Roy Cornelissen and Willem Meints on some more cross device Phone Apps the past few weeks and we currently used RIA services as the backend of our story. With the release of LightSwitch Beta 2 and the nice architecture they use behind the scenes I wanted to give it a shot to Use LightSwitch as the backend of our Phone apps. especially since LightSwitch beta 2 now also has a go live license, we can even roll a production version of the app if we want.

    So I already blogged about using RIA services for you WP7 app here.

    the thing with LightSwitch is, that I needed to figure out a way to make it work the same way. Now since the LigthSwitch team really uses RIA services for their application model, I set the project settings to build a 3 tier Web application and published it to my local IIS instance on my box.

    Now at first you I thought they even might use the same end points as I would create myself when building a domain service, but they generate at the backend one single domain service class that contains all your operations. For each entity you build in the model you will at least find the flowing operations, <entityName>_All and a <entityName>_Single and <entityName>_SingleOrDefault. ALl these operations have one argument of string that can contain additional Query syntax. I have not figured out yet all the possibilities of these strings yet, need to do some more sniffing with fiddler to find how that works. For simplicity sake, I just passed an empty string. Passing a null value will result in an exception when the async call completes!

    The endpoint they use is named http://yourHostName/YourAppName/services/LightSwitchApplication-Implementation-ApplicationDataDomainService.svc

    Now for communication with WP7 I need to use the SOAP endpoint and enable the cookie containers for authentication purposes. Enabling the SOAP endpoint, was extremely easy to do, just add the configuration section to your web.config file after deployment

    <configSections>
    &nbsp;&nbsp;&nbsp;
    <sectionGroup name=“system.serviceModel“>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <section name=“domainServices“ type=“System.ServiceModel.DomainServices.Hosting.DomainServicesSection,&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
    “
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; allowDefinition
    =“MachineToApplication“ requirePermission=“false“
    />
    &nbsp; </sectionGroup>
    </configSections>

    next you go to the System.ServiceModel section and right after the ServiceHostingEnvironment tag you past the following:

    <domainServices>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <endpoints>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <add name=“Soap“&nbsp; type=“Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory,
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Microsoft.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral,
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PublicKeyToken=31bf3856ad364e35
    “
    />
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </endpoints>
    </domainServices>

    For this to function correctly you must register the Microsoft.ServiceModel.DomainService.Hosting assemblies in the GAC or copy the assemblies from the RIA services toolkit to the bin folder of the LightSwitch app.You can find the toolkit assemblies at the following location after install: <installdrive>:Program Files (x86)Microsoft SDKsRIA Servicesv1.0ToolkitLibrariesServer

    Now after adding this, you can browse to the service endpoint location and see the WSDL is now available at this endpoint. So next part is to add a service reference to the WP7 App and use the endpoint where you can find the WSDL. Now calling the LightSwitch DomainService operations is done as follows:

    public MainPage() 
    { 
        InitializeComponent(); 
        BasicHttpBinding binding = new BasicHttpBinding(); 
        EndpointAddress address = new EndpointAddress(&quot;http://YourHost/YourApp&quot; + 
                                                    &quot;/services/LightSwitchApplication-Implementation-    ApplicationDataDomainService.svc/Soap&quot;); 
        binding.EnableHttpCookieContainer = true; 
    
        var client = new     ServiceNameSpace.ApplicationDataDomainServiceSoapClient(binding, address); 
        client.CookieContainer = new CookieContainer(); 
    
        client.EntityName_AllCompleted += new EventHandler&lt;ServiceNameSpace.EntityName_AllCompletedEventArgs&gt;(client_EntityName_AllCompleted); 
        client.EntityName_AllAsync(&quot;&quot;); 
    } 
    
    void client_EntityName_AllCompleted(object sender, ServiceNameSpace.EntityName_AllCompletedEventArgs e) 
    { 
        if (e.Error == null) 
        { 
            yourListBox.ItemsSource= e.Result.RootResults; 
        } 
    }

    And voila, your LightSwitch RIA services are now servicing your WP7 app!

    Cheers,
    Marcel

    Follow my new blog on http://fluentbytes.com

    Share this

Marcel de Vries

View profile

Related IT training

Go to training website

Related Consultancy solutions

Go to infosupport.com

Related blogs

  • Innovative patterns in software quality management

    Innovative patterns in software quality management Tom van den Berg - 2 months ago

  • Developing a Service Fabric service using another host

    Developing a Service Fabric service using another host Tim van de Lockand - 6 months ago

  • Adding a package to your private WinGet.RestSource feed…

    Adding a package to your private WinGet.RestSource feed… Léon Bouquiet - 12 months ago

Related downloads

  • Beslisboom voor een rechtmatig ‘kopietje productie’

  • Klantreferentie: Remmicom zet wetgeving om in intellige…

  • Klantreferentie RDW: Samenwerken voor veilig en vertrou…

  • Klantreferentie BeFrank: Strategische IT voor een innov…

  • Wie durft te experimenteren met data in de zorg?

Related videos

  • mijnverzekeringenopeenrij.nl

    mijnverzekeringenopeenrij.nl

  • Winnaar | Innovation Projects 2017

    Winnaar | Innovation Projects 2017

  • Explore | Info Support & HAN & Poliskluis

    Explore | Info Support & HAN & Poliskluis

  • LifeApps bij HagaZiekenhuis

    LifeApps bij HagaZiekenhuis

  • Info Support | Bedrijfsfilm

    Info Support | Bedrijfsfilm

Nieuwsbrief

* verplichte velden

Contact

  • Head office NL
  • Kruisboog 42
  • 3905 TG Veenendaal
  • T +31 318 552020
  • Call
  • Mail
  • Directions
  • Head office BE
  • Generaal De Wittelaan 17
  • bus 30 2800 Mechelen
  • T +32 15 286370
  • Call
  • Mail
  • Directions

Follow us

  • Twitter
  • Facebook
  • Linkedin
  • Youtube

Newsletter

Sign in

Extra

  • Media Library
  • Disclaimer
  • Algemene voorwaarden
  • ISHBS Webmail
  • Extranet
Beheer cookie toestemming
Deze website maakt gebruik van Functionele en Analytische cookies voor website optimalisatie en statistieken.
Functioneel
Altijd actief
De technische opslag of toegang is strikt noodzakelijk voor het legitieme doel het gebruik mogelijk te maken van een specifieke dienst waarom de abonnee of gebruiker uitdrukkelijk heeft gevraagd, of met als enig doel de uitvoering van de transmissie van een communicatie over een elektronisch communicatienetwerk.
Voorkeuren
De technische opslag of toegang is noodzakelijk voor het legitieme doel voorkeuren op te slaan die niet door de abonnee of gebruiker zijn aangevraagd.
Statistieken
De technische opslag of toegang die uitsluitend voor statistische doeleinden wordt gebruikt. De technische opslag of toegang die uitsluitend wordt gebruikt voor anonieme statistische doeleinden. Zonder dagvaarding, vrijwillige naleving door uw Internet Service Provider, of aanvullende gegevens van een derde partij, kan informatie die alleen voor dit doel wordt opgeslagen of opgehaald gewoonlijk niet worden gebruikt om je te identificeren.
Marketing
De technische opslag of toegang is nodig om gebruikersprofielen op te stellen voor het verzenden van reclame, of om de gebruiker op een website of over verschillende websites te volgen voor soortgelijke marketingdoeleinden.
Beheer opties Beheer diensten Beheer leveranciers Lees meer over deze doeleinden
Voorkeuren
{title} {title} {title}