我对 Silver-light 和 WCF 还很陌生,所以请多多包涵。
我有调用 .svc 服务的银色应用程序。该服务正在通过 https 成功调用,但我也想让它与通过普通 http 的调用一起工作。
我需要对下面的 web.config 和 ServiceReferences.ClientConfig 文件进行哪些修改。
我的 Web.config 文件中的完整system.serviceModel
部分是这样的。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="MyApp.Web.GetData.customBinding" receiveTimeout="00:30:00" sendTimeout="00:30:00" >
<binaryMessageEncoding/>
<httpsTransport/>
</binding>
</customBinding>
</bindings>
<services>
<service name="MyApp.Web.GetData">
<endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.GetData.customBinding" contract="MyApp.Web.GetData" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyApp.Web.GetData">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
我完整的 ServiceReferences.ClientConfig 文件如下
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_GetData">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="//localhost/MyApp.Web/Webservice/GetData.svc"
binding="customBinding" bindingConfiguration="CustomBinding_GetData"
contract="GetData.GetData" name="CustomBinding_GetData" />
</client>
</system.serviceModel>