Duplex sample updated to Silverlight 4

I was following this thread on the Silverlight forums and was asked to update the Duplex sample to Silverlight 4.

Click here to download the code.

More information about Duplex Services are available here:

Happy Silverlighting!

Silverlight 3 Beta and Binary message encoding

Silverlight 3 Beta uses Binary message encoding as a default WCF binding option, this is also the methodology used in the “Silverlight-enabled WCF Service” item template of Visual Studio.

John Papa has posted a nice article explaining the advantages of this binding instead of the “usual” BasicHttpBinding used in Silverlight 2 (other details available here and here), what about the client side? How can I use this new Binding?

These are the steps required for explicitely specifying the new binding in the code:

  • add a “Service Reference” from Visual Studio;
  • initialize and call the service in this way
EndpointAddress address = new EndpointAddress("<Your Service Uri Here>");

CustomBinding binding = new CustomBinding(
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement());

YourServiceRef.ServiceClient svc = new YourServiceRef.ServiceClient(binding, address);

Download the Visual Studio 2008 solution (also tested on Visual Studio 2010 Beta 1:)

Silverlight 3 Duplex Wrap-up

I’ve already blogged about the new Silverlight 3 Beta Duplex support here. In these days I’ve found some interesting articles and tips about this topic, so this is a list of links I’ve found useful:

Silverlight 3 Beta Duplex support

I’m testing the updated Duplex support available in Silverlight 3 Beta, the important news is the possibility to simplify and reduce the code in the client:

  • now it’s possible to use the “Add Service Reference” functionality of Visual Studio to consume the service;
  • in this way you the use of channels can be avoided by simply attaching a callback to an event.

I’ve prepared an example based on the material available on the official documentation, download the complete solution from here.

Silverlight, SOAP Headers, WCF and asmx services

As reported by the Web Services Team, Silverlight 2 supports custom SOAP headers.

A good working example can be found here, but it only uses WCF services, what about the “old” asmx ones?

I’ve modified the “SilverlightHeaders” solution to use both WCF and asmx, using OperationContext in the first case and HttpContext in the last, click here to download the complete solution.

WCF DataContract Serializer and IsReference property

One of the new features of .NET framework 3.5 SP1 is the possibility to serialize an object graph with circular references by using the standard xsd:ID/xsd:IDREF attributes.

Just mark your DataContract attribute with the IsReference=true property:

Silverlight 2 and Duplex-Services deployed to IIS7

I’ve prepared this Silverlight 2 Beta 2 solution based on the example described in the official documentation.

You can try it just following these simple steps:

  • open the solution using Visual Studio 2008;
  • deploy the Wcf Service “DuplexService” to http://localhost/DuplexService;
  • copy the included crossdomain.xml and clientaccesspolicy.xml in c:\inetpub\wwwroot\;
  • run the project “DuplexClientWeb” from within Visual Studio or deploy it to IIS.

Enjoy!

Silverlight and WCF Duplex Services

One of the new features of SL2B2 is the capability to use duplex WCF services.

Dan Wahlin has written two great articles about this topic on his blog:

 

Definitely worth a look!