问题描述
嗨朋友们,
如何以推荐的方式启用WCF SOAP和REST。?
如果你有经验的人在那些chalenging区域
请回复我的想法,并提供我链接,如果你有。
祝福!!
Ramesh
Hi Friends,
How to enable both WCF SOAP and REST in recommanded way.?
If you people who have a experience on those chalenging areas
please revert back to me with your thoughts and provide me link if you have.
Best Wishes!!
Ramesh
推荐答案
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
您的方案中的端点配置示例是
An example of endpoint configuration in your scenario is
<services>
<service name="TestService">
<endpoint address="soap" binding="basicHttpBinding" contract="ITestService"/>
<endpoint address="json" binding="webHttpBinding" behaviorConfiguration="jsonBehavior" contract="ITestService"/>
</service>
</services>
因此,该服务将在
http://www.example.com/soap
http://www.example.com/json
将[WebGet]应用于操作合同以使其成为RESTful。例如
So, the service will be available at
http://www.example.com/soap
http://www.example.com/json
Apply [WebGet] to the operation contract to make it RESTful. e.g.
public interface ITestService
{
[OperationContract]
[WebGet]
string HelloWorld(string text)
}
注意,如果REST服务不在JSON中,则操作的参数不能包含复杂类型。
Note, if the REST service is not in JSON, parameters of the operations can not contain complex type.
这篇关于如何以推荐的方式启用WCF SOAP和REST。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!