Recently I was working on a portable class library(PCL) example in VS2012 to create a proxy class for an external asmx soap service with return types DataTable and DataSet. The easiest way to create a proxy class to add a service reference. In my case, it failed. The add service reference generated code  contains XmlElement and failed to generate response messages with DataTable and DataSet. VS2012 gives a warning for Xml Element.

The alternative way to add service reference is to create a HttpWebRequest to asmx service wsdl and use System.ServiceModel.Description.ServiceDescription to load response xml and parse WSDL. This is one too not supported in PCL.

Because of these limitations, What I think a work around for this is to create a custom wsdl parser or manually construct soap envelopes and parse responses but its not an easiest way to do it and a time consuming.

Some of the limitations of PCL are

1) PCL doesn’t support System.Xml.XmlElement, instead use System.Xml.Linq.XElement

2) PCL doesn’t support System.Data.

3) PCL doesn’t support some of the member classes of System.ServiceModel.Description for example ServiceDescription, WSDLImporter etc.

My project target settings as below

This training kit is designed to help you learn how to utilize visual studio 2010 and framework technologies. it includes presentations, hands-on labs and demos of the following framework technologies

  • C# 4
  • ASP.Net 4
  • Windows 7
  • Entity Framework
  • ADO.Net Data Services
  • Managed Extensibility Framework
  • Windows Communication Foundation
  • Windows Workflow
  • Windows Presentation Foundation

This kit works with Visual Studio 2010 and .Net Framework 4 only. It’ll walk you step by step through loads of content and is a great starter if you’re getting into what’s new in .NET 4.

You can download kit from here Visual Studio 2010 and .Net Framework 4 Training kit

ASP.Net 3.5 SP1 includes a new concept ADO.Net Data service. Commonly you can ask why we need one more service concept if we have WCF, ASMX services already?. Simply I could write a ASMX or WCF service to  provide API interface for my data. Yes its possible, the problem here is we have to write the code for everything(sorting, filtering, joins, CRUD operations etc) from scratch. Also for supporting different formats(JSON, ATOM, XML etc). Additional code required if we wish to expose it as a RESTful service. ADO.Net data services designed specially for these purpose. In a one go, we can a have service that performs CRUD operations, sorting, filtering etc and provides a RESTful interface supporting ATOM feeds and JSON formats without writing too much code and which well works with Entity Framework.

In three steps, you can expose your DB as web service.

  • Create a Entity Model from DB
  • Create a ADO.Net Data Service using Entity model
  • Add some initialisation code

Interestingly,  ADO.Net Data service is built on top of WCF and all the WCF features are available in it.It well supports LinQ. By default ADO.Net data services are RESTful in nature and supports ATOM feeds(default), JSON.

It has advantages and disadvantages as well. The advantages are REST service like URLs when accessing and manipulating data.

For example, An entity model db is with entities Customer, Products (say DB tables , here we treat them as entities). If the data service exposed as SampleDataService.svc then the below are some of the REST urls to access entities

http://<someserver>/SampleDataService.svc/Products (returns all the products as a atom feed by default unless specified)

http://<someserver>/SampleDataService.svc/Customers ( same returns all the customers)

Data service supports additional optional request parameters like $filter, $expand(use for joins) etc.

It supports interceptors and custom service operations which are then used to modify entity output.

Disadvantages are custom service operations with non relational data i,e. service operations to return only the entities defined in the entity model. It can’t return a custom entity that is not defined in the model.

Here I’m not explaining how to create them, there are several other articles already on MSDN and other blogs explaining in detail how to create and consume ADO.Net data services.

Follow these link for more detailed information http://msdn.microsoft.com/en-us/data/bb931106.aspx

I hosted some example services, Soon I’ll provide links.