最近项目中需要使用WCF~~~
WCFHelper中写了一个异步的静态方法(在SOAP头中记录了登录信息)

Public Shared Function AsyncDataService(ByVal objRequest As DataEntity, _
               ByVal callBack As Action(Of DataEntity)) As IAsyncResult
    Dim arReturn As IAsyncResult
    Dim objService As WCFServiceClient = New WCFServiceClient
    Using scope = New OperationContextScope(objService.InnerChannel)
        Dim header As Channels.MessageHeader
        header = Channels.MessageHeader.CreateHeader( _
        C_WCF_HEADER_LOGIN_INFO, C_WCF_NAMESPACE, _
        SingletonProvider(Of LoginInfo).Instance.ToString)
        OperationContext.Current.OutgoingMessageHeaders.Add(header)
        arReturn = objService.BeginDataService(objRequest, Sub(ar As IAsyncResult)
                callBack(TryCast(ar.AsyncState,  _
                WCFServiceClient).EndDataService(ar))
            End Sub, objService)
    End Using
    Return arReturn
End Function

Back