如何移动MSDN“;“自托管”;WCF示例远离本地主机?

如何移动MSDN“;“自托管”;WCF示例远离本地主机?,wcf,wcf-client,Wcf,Wcf Client,我已经通过了,它非常棒,直到我尝试将客户机从我域中的一台机器移动到我域中的另一台机器。当我将客户端peice移动到网络中的另一台机器时,它给了我一个。以下是我所做的: 我定义了一个服务合同(参见下面的代码块1) 我实现了服务合同(参见下面的代码块2) 我创建了一个主机来运行该服务(请参见下面的代码块3) 运行svcutil.exe生成我的代理类和配置文件(请参见下面的代码块4) 将4的输出复制到我的客户端项目中 我创建了一个客户端来连接到我的主机(参见下面的代码块5) 当我在自己的机器(SCOT

我已经通过了,它非常棒,直到我尝试将客户机从我域中的一台机器移动到我域中的另一台机器。当我将客户端peice移动到网络中的另一台机器时,它给了我一个。以下是我所做的:

  • 我定义了一个服务合同(参见下面的代码块1)
  • 我实现了服务合同(参见下面的代码块2)
  • 我创建了一个主机来运行该服务(请参见下面的代码块3)
  • 运行
    svcutil.exe
    生成我的代理类和配置文件(请参见下面的代码块4)
  • 将4的输出复制到我的客户端项目中
  • 我创建了一个客户端来连接到我的主机(参见下面的代码块5) 当我在自己的机器(SCOTT)上运行服务和客户机时,它工作正常。当我在我的机器(SCOTT)上运行服务并在我的虚拟机(SCOTT-VM)上运行客户端时,它会出现以下堆栈跟踪失败:

    Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: SOAP security negotiation with 'http://scott:8000/ServiceModelSamples/Service/CalculatorService' for target 'http://scott:8000/ServiceModelSamples/Service/CalculatorService' failed. See inner exception for more details. ---> System.ComponentModel.Win32Exception: Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account with identity 'host/scott'. If the server is running in a service account (Network Service for example), specify the account's ServicePrincipalName as the identity in the EndpointAddress for the server. If the server is running in a user account, specify the account's UserPrincipalName as the identity in the EndpointAddress for the server.
       at System.ServiceModel.Security.WindowsSspiNegotiation.GetOutgoingBlob(Byte[] incomingBlob)
       at System.ServiceModel.Security.SspiNegotiationTokenProvider.GetNextOutgoingMessageBody(Message incomingMessage, SspiNegotiationTokenProviderState sspiState)
       at System.ServiceModel.Security.IssuanceTokenProviderBase`1.GetNextOutgoingMessage(Message incomingMessage, T negotiationState)
       at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
       --- End of inner exception stack trace ---
    
    Server stack trace:
       at System.ServiceModel.Security.IssuanceTokenProviderBase`1.DoNegotiation(TimeSpan timeout)
       at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout)
       at System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired(SecurityTokenProvider tokenProvider, TimeSpan timeout)
       at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.SecurityChannelFactory`1.ClientSecurityChannel`1.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout)
       at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout)
       at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
    
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ClientBase`1.Open()
       at Client.Module1.Main() in C:\Projects\SKUNK\WCFServiceTutorial\Client\Module1.vb:line 11
    
    (我使用了上面的代码块,这样可以很好地滚动和格式化。我尝试使用引号,但无法读取。)

    对于受过训练的WCF用户来说,这个堆栈跟踪可能存在明显的问题,但我看不出问题所在。首先,我想解决这个问题。第二,我想知道任何好的教程和培训材料。有一些很棒的链接。我已经拉上了我的拉链,供你复习

    谢谢


    代码块 代码块1:

    Imports System.ServiceModel
    
    <ServiceContract(Namespace:="http://Microsoft.ServiceModel.Samples")> _
    Public Interface ICalculator
    
        <OperationContract()> _
        Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double
        <OperationContract()> _
        Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double
        <OperationContract()> _
        Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double
        <OperationContract()> _
        Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double
        <OperationContract()> _
        Function Sin(ByVal n1 As Double) As Double
    
    End Interface
    
    代码块3:

    Imports System.ServiceModel
    Imports System.ServiceModel.Description
    
    Module Module1
    
        Sub Main()
            Dim baseAddress As New Uri("http://scott:8000/ServiceModelSamples/Service")
            Using selfHost As New ServiceHost(GetType(CalculatorService), baseAddress)
                Try
                    ' Add a service endpoint
                    selfHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorService")
                    ' Enable metadata exchange
                    Dim smb As New ServiceMetadataBehavior()
                    smb.HttpGetEnabled = True
                    selfHost.Description.Behaviors.Add(smb)
    
                    selfHost.Open()
                    Console.WriteLine("The service is ready.")
                    Console.WriteLine("Press <ENTER> to terminate service.")
                    Console.WriteLine()
                    Console.ReadLine()
    
                    ' Close the ServiceHostBase to shutdown the service.
                    selfHost.Close()
                Catch ex As Exception
                    Console.WriteLine("An exception occurred: {0}", ex.Message)
                    selfHost.Abort()
                End Try
            End Using
    
        End Sub
    
    End Module
    
    代码块4的输出:
    app.config:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <wsHttpBinding>
                    <binding name="WSHttpBinding_ICalculator" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                        allowCookies="false">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
                        <security mode="Message">
                            <transport clientCredentialType="Windows" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                                algorithmSuite="Default" establishSecurityContext="true" />
                        </security>
                    </binding>
                </wsHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://scott:8000/ServiceModelSamples/Service/CalculatorService"
                    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
                    contract="ICalculator" name="WSHttpBinding_ICalculator">
                    <identity>
                        <userPrincipalName value="{MY_DOMAIN_NAME}" />
                    </identity>
                </endpoint>
            </client>
        </system.serviceModel>
    </configuration>
    
    
    
    generatedProxy.vb:

    '------------------------------------------------------------------------------
    ' <auto-generated>
    '     This code was generated by a tool.
    '     Runtime Version:2.0.50727.4200
    '
    '     Changes to this file may cause incorrect behavior and will be lost if
    '     the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------
    
    Option Strict Off
    Option Explicit On
    
    
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"),  _
     System.ServiceModel.ServiceContractAttribute([Namespace]:="http://Microsoft.ServiceModel.Samples", ConfigurationName:="ICalculator")>  _
    Public Interface ICalculator
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")>  _
        Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")>  _
        Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")>  _
        Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")>  _
        Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Sin", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/SinResponse")>  _
        Function Sin(ByVal n1 As Double) As Double
    End Interface
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")>  _
    Public Interface ICalculatorChannel
        Inherits ICalculator, System.ServiceModel.IClientChannel
    End Interface
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")>  _
    Partial Public Class CalculatorClient
        Inherits System.ServiceModel.ClientBase(Of ICalculator)
        Implements ICalculator
    
        Public Sub New()
            MyBase.New
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String)
            MyBase.New(endpointConfigurationName)
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
    
        Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(binding, remoteAddress)
        End Sub
    
        Public Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Add
            Return MyBase.Channel.Add(n1, n2)
        End Function
    
        Public Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Subtract
            Return MyBase.Channel.Subtract(n1, n2)
        End Function
    
        Public Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Multiply
            Return MyBase.Channel.Multiply(n1, n2)
        End Function
    
        Public Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Divide
            Return MyBase.Channel.Divide(n1, n2)
        End Function
    
        Public Function Sin(ByVal n1 As Double) As Double Implements ICalculator.Sin
            Return MyBase.Channel.Sin(n1)
        End Function
    End Class
    
    '------------------------------------------------------------------------------
    ' 
    '此代码是由工具生成的。
    '运行时版本:2.0.50727.4200
    '
    '对此文件的更改可能会导致不正确的行为,如果
    '代码将重新生成。
    ' 
    '------------------------------------------------------------------------------
    选择严格关闭
    选项显式打开
    _
    公共接口计算器
    _
    函数Add(ByVal n1为Double,ByVal n2为Double)为Double
    _
    函数减法(ByVal n1为Double,ByVal n2为Double)为Double
    _
    函数乘法(ByVal n1为双精度,ByVal n2为双精度)为双精度
    _
    函数除法(ByVal n1为Double,ByVal n2为Double)为Double
    _
    函数Sin(ByVal n1为Double)为Double
    端接口
    _
    公共接口iCalculator通道
    继承ICalculator System.ServiceModel.IClientChannel
    端接口
    _
    部分公共类计算器客户端
    继承System.ServiceModel.ClientBase(ICalculator的)
    电子计算器
    公共分新()
    我的基地,新的
    端接头
    Public Sub New(ByVal endpointConfigurationName作为字符串)
    MyBase.New(endpointConfigurationName)
    端接头
    Public Sub New(ByVal endpointConfigurationName作为字符串,ByVal remoteAddress作为字符串)
    MyBase.New(endpointConfigurationName,remoteAddress)
    端接头
    Public Sub New(ByVal endpointConfigurationName作为字符串,ByVal remoteAddress作为System.ServiceModel.EndpointAddress)
    MyBase.New(endpointConfigurationName,remoteAddress)
    端接头
    Public Sub New(ByVal绑定为System.ServiceModel.Channels.binding,ByVal remoteAddress为System.ServiceModel.EndpointAddress)
    MyBase.New(绑定,远程地址)
    端接头
    公共函数Add(ByVal n1作为Double,ByVal n2作为Double)作为Double实现了ICalculator.Add
    返回MyBase.Channel.Add(n1,n2)
    端函数
    公共函数Subtract(ByVal n1作为Double,ByVal n2作为Double)作为Double实现ICalculator.Subtract
    返回MyBase.Channel.Subtract(n1,n2)
    端函数
    公共函数Multiply(ByVal n1作为Double,ByVal n2作为Double)作为Double实现ICalculator.Multiply
    返回MyBase.Channel.Multiply(n1,n2)
    端函数
    公共函数Divide(ByVal n1作为Double,ByVal n2作为Double)作为Double实现了ICalculator.Divide
    返回MyBase.Channel.Divide(n1,n2)
    端函数
    公共函数Sin(ByVal n1作为Double)作为Double实现ICalculator.Sin
    返回MyBase.Channel.Sin(n1)
    端函数
    末级
    
    代码块5:

    Imports System.ServiceModel
    
    Module Module1
    
        Sub Main()
            'Dim client As MyCalcServiceRef.CalculatorClient = New MyCalcServiceRef.CalculatorClient()
            '' Step 1: Create an endpoint address and an instance of the WCF Client.
            Dim epAddress As New EndpointAddress("http://scott:8000/ServiceModelSamples/Service/CalculatorService")
            Dim Client As New CalculatorClient(New WSHttpBinding(), epAddress)
    
            Client.Open()
    
            'Step 2: Call the service operations.
            'Call the Add service operation.
            Dim value1 As Double = 100D
            Dim value2 As Double = 15.99D
            Dim result As Double = client.Add(value1, value2)
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result)
    
            'Call the Subtract service operation.
            value1 = 145D
            value2 = 76.54D
            result = client.Subtract(value1, value2)
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result)
    
            'Call the Multiply service operation.
            value1 = 9D
            value2 = 81.25D
            result = client.Multiply(value1, value2)
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result)
    
            'Call the Divide service operation.
            value1 = 22D
            value2 = 7D
            result = client.Divide(value1, value2)
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result)
    
            'Call the Sin service operation.
            value1 = 144D
            result = client.sin(value1)
            Console.WriteLine("Sin({0}) = {1}", value1, result)
    
            ' Step 3: Closing the client gracefully closes the connection and cleans up resources.
            client.Close()
    
            Console.WriteLine()
            Console.WriteLine("Press <ENTER> to terminate client.")
            Console.ReadLine()
        End Sub
    
    End Module
    
    导入System.ServiceModel
    模块1
    副标题()
    '作为MyCalcServiceRef.CalculatorClient的Dim客户端=新建MyCalcServiceRef.CalculatorClient()
    “”步骤1:创建WCF客户端的终结点地址和实例。
    Dim eAddress作为新端点地址(“http://scott:8000/ServiceModelSamples/Service/CalculatorService")
    Dim客户端作为新的CalculatorClient(新的WSHttpBinding(),eAddress)
    Client.Open()
    '步骤2:调用服务操作。
    '调用添加服务操作。
    尺寸值1为双精度=100D
    尺寸值2为双精度=15.99D
    Dim结果为Double=client.Add(值1,值2)
    WriteLine(“Add({0},{1})={2}”,value1,value2,result)
    '调用减法服务操作。
    值1=145D
    值2=76.54D
    结果=客户端。减去(值1,值2)
    WriteLine(“Subtract({0},{1})={2}”,value1,value2,result)
    '调用乘法服务操作。
    值1=9D
    值2=81.25D
    结果=客户端。乘法(值1,值2)
    WriteLine(“Multiply({0},{1})={2}”,value1,value2,result)
    '调用Divide服务操作。
    值1=22D
    值2=7D
    结果=client.Divide(值1、值2)
    WriteLine(“Divide({0},{1})={2}”,value1,value2,result)
    '调用Sin服务操作。
    价值1=
    
    '------------------------------------------------------------------------------
    ' <auto-generated>
    '     This code was generated by a tool.
    '     Runtime Version:2.0.50727.4200
    '
    '     Changes to this file may cause incorrect behavior and will be lost if
    '     the code is regenerated.
    ' </auto-generated>
    '------------------------------------------------------------------------------
    
    Option Strict Off
    Option Explicit On
    
    
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0"),  _
     System.ServiceModel.ServiceContractAttribute([Namespace]:="http://Microsoft.ServiceModel.Samples", ConfigurationName:="ICalculator")>  _
    Public Interface ICalculator
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Add", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/AddResponse")>  _
        Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Subtract", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/SubtractResponse")>  _
        Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Multiply", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/MultiplyResponse")>  _
        Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Divide", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/DivideResponse")>  _
        Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double
    
        <System.ServiceModel.OperationContractAttribute(Action:="http://Microsoft.ServiceModel.Samples/ICalculator/Sin", ReplyAction:="http://Microsoft.ServiceModel.Samples/ICalculator/SinResponse")>  _
        Function Sin(ByVal n1 As Double) As Double
    End Interface
    
    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")>  _
    Public Interface ICalculatorChannel
        Inherits ICalculator, System.ServiceModel.IClientChannel
    End Interface
    
    <System.Diagnostics.DebuggerStepThroughAttribute(),  _
     System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")>  _
    Partial Public Class CalculatorClient
        Inherits System.ServiceModel.ClientBase(Of ICalculator)
        Implements ICalculator
    
        Public Sub New()
            MyBase.New
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String)
            MyBase.New(endpointConfigurationName)
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As String)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
    
        Public Sub New(ByVal endpointConfigurationName As String, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(endpointConfigurationName, remoteAddress)
        End Sub
    
        Public Sub New(ByVal binding As System.ServiceModel.Channels.Binding, ByVal remoteAddress As System.ServiceModel.EndpointAddress)
            MyBase.New(binding, remoteAddress)
        End Sub
    
        Public Function Add(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Add
            Return MyBase.Channel.Add(n1, n2)
        End Function
    
        Public Function Subtract(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Subtract
            Return MyBase.Channel.Subtract(n1, n2)
        End Function
    
        Public Function Multiply(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Multiply
            Return MyBase.Channel.Multiply(n1, n2)
        End Function
    
        Public Function Divide(ByVal n1 As Double, ByVal n2 As Double) As Double Implements ICalculator.Divide
            Return MyBase.Channel.Divide(n1, n2)
        End Function
    
        Public Function Sin(ByVal n1 As Double) As Double Implements ICalculator.Sin
            Return MyBase.Channel.Sin(n1)
        End Function
    End Class
    
    Imports System.ServiceModel
    
    Module Module1
    
        Sub Main()
            'Dim client As MyCalcServiceRef.CalculatorClient = New MyCalcServiceRef.CalculatorClient()
            '' Step 1: Create an endpoint address and an instance of the WCF Client.
            Dim epAddress As New EndpointAddress("http://scott:8000/ServiceModelSamples/Service/CalculatorService")
            Dim Client As New CalculatorClient(New WSHttpBinding(), epAddress)
    
            Client.Open()
    
            'Step 2: Call the service operations.
            'Call the Add service operation.
            Dim value1 As Double = 100D
            Dim value2 As Double = 15.99D
            Dim result As Double = client.Add(value1, value2)
            Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result)
    
            'Call the Subtract service operation.
            value1 = 145D
            value2 = 76.54D
            result = client.Subtract(value1, value2)
            Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result)
    
            'Call the Multiply service operation.
            value1 = 9D
            value2 = 81.25D
            result = client.Multiply(value1, value2)
            Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result)
    
            'Call the Divide service operation.
            value1 = 22D
            value2 = 7D
            result = client.Divide(value1, value2)
            Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result)
    
            'Call the Sin service operation.
            value1 = 144D
            result = client.sin(value1)
            Console.WriteLine("Sin({0}) = {1}", value1, result)
    
            ' Step 3: Closing the client gracefully closes the connection and cleans up resources.
            client.Close()
    
            Console.WriteLine()
            Console.WriteLine("Press <ENTER> to terminate client.")
            Console.ReadLine()
        End Sub
    
    End Module