Back to the "Steady Silverlight 3.0 series Article index"
Introduced
New features of Silverlight 3.0 communication
Binary XML communication-communicating with WCF services, using binary XML to pass data (improve transport performance)
Local Area Connection-allows direct communication between two Silverlight programs on the client (not through the server)
Online Demo
Http://www.cnblogs.com/webabcd/archive/2009/08/04/1538238.html
Example
1. Demo of data passing in binary XML
Service side (WCF)
Binaryxmlservice.svc
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
namespace Silverlight30.Service
{
/**//// <summary>
/// 一个简单的 WCF 服务
/// </summary>
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class BinaryXmlService
{
[OperationContract]
public string Hello(string name)
{
return "Hello: " + name;
}
}
}
Web.config
<system.serviceModel>
<bindings>
<customBinding>
<binding name= "CUSTOMBINDING0" >
<binarymessageencoding/>
</binding>
</customBinding>
</bindings>
<servicehostingenvironment aspnetcompatibilityenabled= "true"/>
<behaviors>
<serviceBehaviors>
<behavior name= "Silverlight30.Service.BinaryXmlServiceBehavior" >
<servicemetadata httpgetenabled= "true"/>
<servicedebug includeexceptiondetailinfaults= "false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorconfiguration= "Silverlight30.Service.BinaryXmlServiceBehavior"
Name= "Silverlight30.Service.BinaryXmlService" >
<endpoint address= "" binding= "CustomBinding" bindingconfiguration= "CUSTOMBINDING0"
contract= "Silverlight30.Service.BinaryXmlService"/>
<endpoint address= "Mex" binding= "mexHttpBinding" contract= "IMetadataExchange"/>
</service>
</services>
</system.serviceModel>