At Mix 2010, ScottGu talked about the developer story of Windows Phone 7. As you know by now, that the developer story is on Silverlight. I have also seen some questions regarding Windows Phone and whether RIA Services can be used part in it.
Unfortunately, there is no in built support for the Mobile platform in RIA Services V1.0. I know that is a big bummer because every Silverlight developer is now a windows phone developer. Rest assured we do think RIA Services support for Windows Phone is very important, but it will not make it in our V1.0.
With that said, you can still enable a Windows Phone 7 application to communicate with a DomainService and here is how…
At PDC 09, we made a big change, where every DomainService is now a WCF Service. Windows Phone 7 has support for talking to a WCF Service and we can leverage that to our advantage and create a mobile application that talks to a domain service. Yes, you do not get the rich client experience RIA Services provides for Silverlight, but you still get all the benefits of the server richness in the V1 release.
Here is how you would do that:-
I am going to skip over the section on how to create a domain service. You can find that at @brada’s post about exposing data from entity framework. Next we are going to configure the domain service to expose a soap endpoint.
Now that you have have a DomainService configured, we are going to configure it to expose a soap endpoint. In the PDC preview bits this was exposed by default, but we have now scaled that back for various reason. In the RC release you would need to configure your DomainService to be exposed as a WCF Soap Endpoint. Here is how you would do that (assuming you have created a domain service already):-
5: <add name="soap" type="Microsoft.ServiceModel.DomainServices.Hosting.SoapXmlEndpointFactory, Microsoft.ServiceModel.DomainServices.Hosting, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
2: <sectionGroup name="system.serviceModel">
3: <section name="domainServices" type="System.ServiceModel.DomainServices.Hosting.DomainServicesSection, System.ServiceModel.DomainServices.Hosting, Version=220.127.116.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
Now that we have configured our DomainService to expose a SOAP endpoint, we can now write a Windows Phone application that talks to it.
1: public override string ToString()
3: return LastName+", "+FirstName +" Title: " +Title;
1: public void LoadEmployee()
3: ServiceReference1.DomainService1soapClient client = new ServiceReference1.DomainService1soapClient();
4: client.GetEmployeesCompleted += new EventHandler<ServiceReference1.GetEmployeesCompletedEventArgs>(client_GetEmployeesCompleted);
9: void client_GetEmployeesCompleted(object sender, ServiceReference1.GetEmployeesCompletedEventArgs e)
11: this.listBox1.ItemsSource = e.Result.RootResults;
There is a very good sample posted at our code gallery site, that explains how you can do CRUD operation with the SOAP endpoint of a DomainService. You can find it here.
Deepesh, EXCELLENT article.
>>There is a very good sample posted at our code gallery site, that explains how you can do CRUD operation with the SOAP endpoint of a DomainService. You can find it here.<<
Are you referring to "HRApp_WPF_VS2010" project?
Yes Ben!, I am referring to HRApp_WPF example.
In that last snippet, I was thinking I'd see a domaincontext - is this client a domaincontext or just a normal wcf client proxy ?
Nice! Saved me a lot of time. *thumbs up*
After I added the service reference to the windows phone application I got an empty reference.cs file! It cannot generate the code for it but I created a windows app project then added the same service to it and it worked. That means it cannot create the proxy when client is a windows phone application. Any idea? Thanks.
Mai i know how to call a java web services in wp7?