newtelligence poweredRSS 2.0
# Saturday, January 16, 2010

This post is part of my PDC09 Conference Notes series. These are my raw notes taken while watching the various session videos from PDC09. Refer to my original post for some conventions I tried to use.

PDC Session Link: Networking and Web Services in Silverlight

This session went over the different ways to expose data to a Silverlight application. Data access requirements for Silverlight was grouped in two ways and presented as the following graphic:

image

Each example fell somewhere on the X/Y axis of the chart above. Resource Centric was explained to be CRUD operations, while operation centric was more behavior driven.

Forms Over Data

The first examples were your typical forms over data applications, which are Resource Centric and follow a Request/Reply model.

If you control, and have direct access to the data, then RIA services was recommended. Aside from a short demo, not a lot of time was spent on RIA services, as there are other presentations that get into the details.

Another option for when you control the data, is to use WCF Data Services, which exposes your data in a RESTFul manner that adheres to the open data protocol (OData). In addition to data you control, services like SharePoint expose the data contained with-in via the open data protocol as well. The advantages to using OData sources over public REST services, is that more is known about the data, so you get a better development experience.

If you are working with a public data store exposed with REST, and it’s not OData, then use the enhanced (for Silverlight 4) ClientHttp library. It has a good programming model, and a lot of the deficiencies in previous versions have been solved. For example there is now support for Basic HTTP Authentication secured with SSL.

2 Way and Streaming

The second group of examples looked at duplex and streaming scenarios. The first example was a chat application which is an operation centric example that has some request/reply elements, but mainly users a duplex model. WCF was the recommend technology to support the duplex model. The included binary encoder provided a 71% performance improvement over the standard text encoder, even over HTTP. Binary has been the default encoder since Silverlight 3, but is only useful when both endpoints are .Net applications.

Duplex itself can be setup in your WCF bindings in one of two ways. For internet scenarios, you will need to use an HTTP binding, which is a polling based duplex model. While not present in the beta that was released at PDC, there are plans to enable HTTP Chunking, which would allow for multiple messages per HTTP request to increase performance. For intranet scenarios, you can use the NetTcp binding for the best performance. Remember, since this is WCF, you code once, and just change your bindings as needed.

Silverlight 4 supports UDP multicast, but it is pretty much an intranet only solution, as your network must be configured to support UDP multicast.

There is a new Silverlight TCP Socket Policy server project template in the online template gallery (accessible in VS 2010). This makes it very easy to setup the policy server to allow cross domain socket calls for your Silverlight application. An enhancement being considered for Silverlight 4 is that if the application has been elevated, then you will not need to worry about policies.

Saturday, January 16, 2010 10:49:01 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Conference Notes | Data Access | Silverlight
# Wednesday, December 02, 2009

Tomorrow night I am presenting at the Madison .Net Users group. Tonight, I am pulling my hair out, trying to get my demos to work. How far am I? Well I’m on my second demo, but the first one involves 0 programming, so I don’t think that counts.

What is was getting in my way, was a nasty System.Data.Services.Client.DataServiceRequestException, complaining of an invalid DateTime value…somewhere.

System.Data.Services.Client.DataServiceRequestException was unhandled
  Message=An error occurred while processing this request.
  Source=Microsoft.Data.Services.Client
  StackTrace:
       at System.Data.Services.Client.DataServiceContext.SaveResult.HandleBatchResponse()
       at System.Data.Services.Client.DataServiceContext.SaveResult.EndRequest()
       at System.Data.Services.Client.DataServiceContext.SaveChanges(SaveChangesOptions options)
       at System.Data.Services.Client.DataServiceContext.SaveChanges()
       at Demo1.Program.AddEmployees() in C:\_Files\Projects\Demo1\Demo1Completed\Demo1Completed\Program.cs:line 48
       at Demo1.Program.Main(String[] args) in C:\_Files\Projects\Demo1\Demo1Completed\Demo1Completed\Program.cs:line 19
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Data.Services.Client.DataServiceClientException
       Message=<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<error xmlns="
http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
  <code></code>
  <message xml:lang="en-US">Error reading syndication item: 'Error in line 5 position 14. An error was encountered when parsing a DateTime value in the XML.'.</message>
</error>
       Source=Microsoft.Data.Services.Client
       StatusCode=400
       StackTrace:
            at System.Data.Services.Client.DataServiceContext.SaveResult.<HandleBatchResponse>d__20.MoveNext()
       InnerException:

After installing Fiddler so I could analyze the post and it’s subsequent response, I tried setting the Modified and Created properties on the Entity to DateTime.Now to give them an actual value. The Modified and Created properties are on all SharePoint list objects. I hadn’t bothered setting them, because they were of type DateTime? and I assumed that SharePoint would set them. As a matter of fact, I watched a PDC session on this very topic and blogged about it. In the demo, the only thing Pablo set was the name and the job title and posted it via CURL, and it worked.

I tried setting the values to null, but I got the same error (and why wouldn’t I). I ended up setting the values to DateTime.Min value. This allows the POST operation to succeed, and the Created and Modified values are correctly set by SharePoint.

Other notes of interest:

  • Even though I installed VS 2010 with .Net 4.0, I still had to install the Ado.Net Data services 1.5 CTP2 for SharePoint 2010 to expose data via ListData.svc
  • When building an application in VS 2010 with the .Net 4.0, System.Data.Services.Client is added for you when you add a Service Reference. You do not need to add a reference to Microsoft.Data.Services.Client in the CTP 2.
  • Be sure to check out the different SaveChangesOptions available when you call SaveChanges for your service. The batch option really speeds things up, but if one update fails, they all fail.
Wednesday, December 02, 2009 4:36:17 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Data Access | Programming | SharePoint
# Wednesday, November 25, 2009

This post is part of my PDC09 Conference Notes series. These are my raw notes taken while watching the various session videos from PDC09. Refer to my original post for some conventions I tried to use.

FT12 -WCF Data Services: What's new the RESTful data services framework (Pablo Castro)

  • Name changed from ADO.Net Data Services to WCF Data Services
  • REST
    • REST is not a Protocol, standard, or Format
    • REST is an architectural style
      • Decoupling
      • Scalability
      • Layering
    • Interesting way of defining REST. I always thought of it as some type of standard based on HTTP (verbs).
  • Resources
    • Represents the state of each of the entities your are modeling
    • These resources (state) are the only thing that is viewable from the outside. There is no behavior.
    • Each resource has an address. In this case, it's the URL
    • Uniform Interface: Removes ambiguity of calls by constrain a system to a know interface.
      • In REST, you have GET, PUT, DELETE and POST. You do not have ApproveOrder, VerifyCreditCard, etc.
  • Date Service is not a gateway to the database
    • There is almost always some type of business logic between the service and the data store
    • I think that this business logic is a subset of what you might find in a Line of Business app, with additional logic as required in order to properly expose via a service.
    • The business logic could be responsible for security, and performance considerations (i.e. don't allow something that will do a SELECT * FROM Table, where table has millions of rows).
  • Open Data Protocol (Astoria => Ado.Net DS => WCF Data services)
    • RESTful over http
    • Poke-able (just open a browser and type a URL and see what comes back)
    • HTTP: Transport, interaction model, control information in headers
    • AtomPub: Format, introduces things like collections and links.
    • Team added extensions to AtomPub as needed
    • Introduced a json serialization option, which is useful when consuming from javascript.
  • URL
    • The URL is independent of the format of the data returned (json, atom, etc). So you can pass the URL around and it will not impact the format. The format is defined in the GET request (accept: applicat/json).
    • Extra stuff goes in query string (?). Use & to append, just like normal query string.
    • (#): Query by primary key. /Categories(6)/Products would return all products for Category 6
    • Filter strings: ?#filter=Color eq 'Red'
    • Return first x rows: $top=#
    • Sorting: $orderby=ColumnName
    • Eger Load: $expand=ChildCollectionName
    • Only get certain columns: $select=Column1,Column2
  • Where used
    • .Net
    • Sharepoint 2010 (install/enable Astoria?, and then you can access all sharepoint data from /vti_bin/listdata.svc/ListName). There is full business logic running, so it will check for authentication, update everything as necessary when you update the actual data.
    • Reporting Services
    • Azure Table Storage
    • Codename "Dallas"
    • Microsoft Media Room
    • Open Government data initiative
    • 3rd Parties
      • IBM WebSpehere Extreme Scale
      • Db4o
      • Telerik Open Access
      • LinqPad
  • VS Support
    • Add Service Reference now supports consuming data from the Open Data Protocol (needs to expose meta data)
    • You'll get a data context type after adding the service reference
    • Do something like: MyDataContextType svc = new MyDataContextType(URL), and then you can drill down into svc to access the various collections of entities that are exposed. Has support for adding (method), and I'm assuming updating as well.
    • Full support for linq.
    • It would be interesting to view the SQL being generated behind the scenes using Query Analyzer
    • You can view the service as a diagram and get a schema diagram.
  • Excel 2010 with Power Pivot
    • Import a data feed using just the URL from WCF Data Services
    • And then you can just work with it in Excel
    • Works with the open data access for SharePoint as well.
  • Latest version of SSRS (must be SQL 2008 R2)
    • Every report has it's data exposed via this open data protocol.
    • Browse to the report, the new report viewer has a button that allows you to export as feed.
Wednesday, November 25, 2009 3:03:36 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Conference Notes | Data Access | Sql
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Copyright 2010
Adam Salvo
Sign In
Statistics
Total Posts: 234
This Year: 13
This Month: 1
This Week: 1
Comments: 34
Themes
Pick a theme:
All Content 2010, Adam Salvo
DasBlog theme 'Business' created by Christoph De Baene (delarou)