您好,目前我在 FW3.5 下有旧版 WCF 服务。使用一些 SilverLigt 应用程序,我需要扩展这个 WCF 服务以支持 JSON 格式并将其调用为 JavaScript 应用程序,目前服务看起来像
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Alcatraz
{
[OperationContract]
[FaultContract(typeof(SomeError))]
public SomeClass DoSomething(SomeClass data)
{
}
}
据我所知,为了支持 WCF 服务的 JSON 格式,我需要将 WebInvoke 属性添加到方法中
[WebInvoke(Method = "GET",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json,
UriTemplate = "players")]
将属性添加[DataContract]
到SomeClass类。但我不确定如果我添加这个,所有应用程序都会以同样的方式工作吗?
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add name="silverlightFaults" type="myNS.WCF.SilverlightFaultBehavior, SilverlightFaultBehavior, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/>
</behaviorExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="binaryHttpBinding" allowCookies="true" receiveTimeout="00:02:00" sendTimeout="00:02:00" openTimeout="00:02:00" closeTimeout="00:02:00">
<binaryMessageEncoding/>
<httpTransport maxReceivedMessageSize="655360" maxBufferSize="655360"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="SilverlightFaultBehavior">
<silverlightFaults/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="myNS.WCF.MyServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="myNS.WCF.MyServiceBehavior" name="myNS.WCF.MyService">
<endpoint address="" binding="customBinding" bindingConfiguration="binaryHttpBinding" contract="myNS.WCF.MyService" behaviorConfiguration="SilverlightFaultBehavior"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
</system.serviceModel>
我需要做什么才能与其他客户端兼容?