开发者

WCF method call from java script

开发者 https://www.devze.com 2023-03-22 23:00 出处:网络
I am implementing a WCF service library. You add a new code file that contains the following code开发者_开发知识库 segment.

I am implementing a WCF service library. You add a new code file that contains the following code开发者_开发知识库 segment.

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 

I build the service library and deploy its assembly to an IIS application. I need to ensure that the GetCurrentRate method can be called from JavaScript. What should I do?


Add a file named Service.svc to the IIS application. then Add the following code segment to the file.

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

精彩评论

暂无评论...
验证码 换一张
取 消