使用JSON WCF服务与.net 3.5客户端 [英] Consume Json WCF service with .Net 3.5 client
问题描述
我在访问返回的Json一个WCF Web服务的一些问题。 Usign WCF测试客户端,我想用什么样的配置,但此配置是针对.NET 4.0和我的客户端应用程序是.NET 3.5(有没有可能升级为现在)。这是我的行为在.NET 4.0中的配置:
I'm having some issues accessing a WCF Web service that returns Json. Usign the WCF Test Client, I figured what config to use but this config is for .Net 4.0 and my client app is in .Net 3.5 (with no possibility for upgrade for now). This is the configuration of my behavior in .Net 4.0:
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Xml" />
</behavior>
</endpointBehaviors>
</behaviors>
不幸的是,这2个属性不会在.NET 3.5中存在。我能做些什么,以指定该为我的客户(code或其它配置)?
Unfortunately, these 2 attributes don't exist in .Net 3.5. What can I do to specify this for my client (code or other configurations) ?
感谢
推荐答案
在3.5,你不能在配置设置这些值,但是你可以设置则在code,请参见:<一href="http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpbehavior.defaultoutgoingresponseformat(v=vs.90).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpbehavior.defaultoutgoingresponseformat(v=vs.90).aspx
In 3.5 you cannot set these values in config, but you can set then in code, see: http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpbehavior.defaultoutgoingresponseformat(v=vs.90).aspx
默认值是XML,您发布的配置的例子也是XML,但是在你的问题的案文说,服务返回JSON。
The default value is XML, the config example you posted is also XML, but in the text of your question says that the service returns JSON.
这篇关于使用JSON WCF服务与.net 3.5客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!