gpt4 book ai didi

javascript - 使用 WebScriptEndpoint 使用 javascript 使用 WCF 服务

转载 作者:行者123 更新时间:2023-11-28 03:43:58 25 4
gpt4 key购买 nike

我在网上搜索但没有找到任何合适的文章解释如何使用 javascript 使用 WCF 服务,尤其是 WebScriptEndpoint。

任何人都可以对此给出任何指导吗?

谢谢

最佳答案

这是一篇关于 REST 服务的好文章:http://msdn.microsoft.com/en-us/magazine/dd315413.aspx

总而言之,您需要一个配置了 webHttpBinding 的端点。此端点应具有启用 webHttp 的行为:

<services>
<service name="TestService">
<endpoint address="test" binding="webHttpBinding" behaviorConfiguration="restBehavior" contract="ITestService"/>
</service>
</services>

行为:

<behavior name="restBehavior">
<webHttp/>
</behavior>

然后在你的服务界面中:

[ServiceContract]
public interface ITestService
{
[OperationContract]
[WebGet(UriTemplate = "test?p={p}", ResponseFormat = WebMessageFormat.Json)]
string Test(string p);
}

您可以使用 WebGet 或 WebInvoke 属性(取决于您是要 GET 还是 POST)...

关于javascript - 使用 WebScriptEndpoint 使用 javascript 使用 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8149954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com