【问题标题】:WCF method call from java script来自 javascript 的 WCF 方法调用
【发布时间】:2011-07-23 17:29:27
【问题描述】:

我正在实现一个 WCF 服务库。您添加一个包含以下代码段的新代码文件。

Namespace ContosoWCF 
<ServiceContract()> 
Public Interface IRateService 
<OperationContract()> 
Function GetCurrentRate() As Decimal 
End Interface 

Partial Public Class RateService
Implements IRateService 
Public Function GetCurrentRate() As Decimal _ 
Implements IRateService.GetCurrentRate 
Dim currentRate As Decimal = GetRateFromDatabase() 
Return currentRate 
End Function 
End Class 
End Namespace 

我构建服务库并将其程序集部署到 IIS 应用程序。我需要确保可以从 JavaScript 调用 GetCurrentRate 方法。我该怎么办?

【问题讨论】:

    标签: javascript asp.net wcf iis


    【解决方案1】:

    将名为 Service.svc 的文件添加到 IIS 应用程序。然后将以下代码段添加到文件中。

    <%@ ServiceHost Service="ContosoWCF.RateService" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-12
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多