开发者

Does anyone know how to access the wcf service by a client using channel factory?

开发者 https://www.devze.com 2023-03-03 00:53 出处:网络
I tried this one...but its not working.. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

I tried this one...but its not working..

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim channel As New ChannelFactory(Of IWidgetServiceProxy)(
                                 New WSHttpBinding(), 
                                 "http://localhost:4676/WidgetServiceProxy.svc")
     Dim client As IWidgetServiceProxy = channel.CreateChannel()

     Dim str As String = client.GetWidgetInstanceTitle()


     Response.Write(str)
     'ProcessStatuses(resp)

End Sub
开发者_运维百科


This code worked for me :

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)        Handles Me.Load

    Dim intr As IWc fInterface
    Dim chnl As ChannelFactory(Of IWcfInterface) = New ChannelFactory(Of IWcfInterface)(New WebHttpBinding(), "http://localhost:49821/Service1.svc")
    chnl.Endpoint.Behaviors.Add(New WebHttpBehavior())
    intr = chnl.CreateChannel()

    Using New OperationContextScope(DirectCast(intr, IContextChannel))

        Dim rspnse As List(Of UserDetails) = intr.GetDataFromDB()
        GridView1.DataSource = rspnse
        GridView1.DataBind()
    End Using
End Sub
0

精彩评论

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

关注公众号