B
blutner
Hello,
I have got a little test application, which provides an WCF service
and wants to consume it as well. The access does only succeed for the
case, that the consumption is done by another application instance,
but that's not really the thing I want. My question now is, if my
problem is gernerally solveable, and if so, in which way I have to
change my code.
Thank you for your help!
Robert
-> ITestService.vb
Public Interface ITestService
Function HelloWorld() As String
End Interface
-> TestService.vb
Public Class TestService
Implements ITestService
Public Function HelloWorld() As String Implements
ITestService.HelloWorld
Return "Hello World!"
End Function
End Class
-> FrmMain.vb
Public Class FrmMain
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
' Provide the service!
Dim host As New ServiceModel.ServiceHost(GetType(TestService))
host.Open()
MsgBox("Service started.")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
' Connect to the service!
Dim address As New ServiceModel.EndpointAddress("net.pipe://localhost/
TestHost")
Dim binding As New ServiceModel.NetNamedPipeBinding()
Dim service As ITestService = ServiceModel.ChannelFactory(Of
ITestService).CreateChannel(binding, address)
MessageBox.Show(service.HelloWorld())
End Sub
End Class
--> app.config
At: http://clipboard.volectra.de/index.php?page=show&contentid=41
I have got a little test application, which provides an WCF service
and wants to consume it as well. The access does only succeed for the
case, that the consumption is done by another application instance,
but that's not really the thing I want. My question now is, if my
problem is gernerally solveable, and if so, in which way I have to
change my code.
Thank you for your help!
Robert
-> ITestService.vb
Public Interface ITestService
Function HelloWorld() As String
End Interface
-> TestService.vb
Public Class TestService
Implements ITestService
Public Function HelloWorld() As String Implements
ITestService.HelloWorld
Return "Hello World!"
End Function
End Class
-> FrmMain.vb
Public Class FrmMain
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
' Provide the service!
Dim host As New ServiceModel.ServiceHost(GetType(TestService))
host.Open()
MsgBox("Service started.")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
' Connect to the service!
Dim address As New ServiceModel.EndpointAddress("net.pipe://localhost/
TestHost")
Dim binding As New ServiceModel.NetNamedPipeBinding()
Dim service As ITestService = ServiceModel.ChannelFactory(Of
ITestService).CreateChannel(binding, address)
MessageBox.Show(service.HelloWorld())
End Sub
End Class
--> app.config
At: http://clipboard.volectra.de/index.php?page=show&contentid=41