WCF method call from java script
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" %>
精彩评论