Silverlight使用WCF实现数据通信

按步建了service和serviceReference之后,还需要修改webconfig才能实现通信。

原文件是:

<system.serviceModel> 
<behaviors>
<serviceBehaviors>
<behavior name="SilverlightDBDemo.Web.DBServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="customBinding0">
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="SilverlightDBDemo.Web.DBServiceBehavior"
name="SilverlightDBDemo.Web.DBService">
<endpoint address="" binding="customBinding" bindingConfiguration="customBinding0"
contract="SilverlightDBDemo.Web.DBService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>

首先将customBinding改成BasicBinding:

<bindings> 
<basicHttpBinding>
<binding name="BasicHttpBinding_IDataService"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxDepth="2147483647"
maxNameTableCharCount="2147483647"
maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
</bindings>

 

然后修改EndPointAddress:

<endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_DBService"      
contract=
"SilverlightDBDemo.Web.DBService" /

 

这样就可以实现wcf数据通信了。

原文地址:http://silverlightchina.net/html/tips/2011/0730/9382_2.html


 

posted @ 2012-03-26 21:16  左手边的爱  阅读(209)  评论(0编辑  收藏  举报