我有如下代码:
Public Class xxxSvcHostFactory
Inherits ServiceHostFactory
Protected Overrides Function CreateServiceHost(ByVal serviceType As Type, ByVal baseAddresses As Uri()) As ServiceHost
Dim result As New WebServiceHost2(serviceType, True, baseAddresses)
Return result
End Function
End Class
服务合同定义如下:
<ServiceContract()>
Public Interface IxxxSvc
<Description("")>
<OperationContract()>
<WebGet(ResponseFormat:=WebMessageFormat.Json,
UriTemplate:="CustomerDetails?id={CustomerId}")>
Function GetCustomerDetails(ByVal CustomerId As String) As Customer
End Interface
Public Class MySvc
Implements IxxxSvc
Public Function GetCustomerDetails(ByVal CustomerId As String) As Customer Implements IxxxSvc.GetCustomerDetails
.
.
.
End Function
End Class
CreateServiceHost 什么时候执行?
是针对每个呼叫,还是针对每个传输会话,还是在应用程序启动时?
ServiceHost 什么时候过期?
如果我实现静态变量,它可以通过多个会话(比如来自 IE 和 Firefox)使用。如何维护特定会话的静态变量(例如,如果我从 IE 访问,当我从 FF 访问时不应共享同一个会话)。
我在我的应用程序中使用 WCF REST 功能(核心 REST 而不是 REST Starter 工具包)。谢谢