使用非本地主机域使用Window Service托管WCF服务

时间:2012-10-17 08:52:20

标签: c# wcf web-services

我想通过窗口服务而不是IIS来托管基于互联网的net-tcp WCF服务? 我想知道的是,端点URI是否可能是非基于非localhost域的URI之外的其他URI。 因此对于例如我想访问<http://dev1/myservice>而非标准<http://localhost:90/myservice&gt;的服务。几乎所有记录的例子都提到了这一点。 我正在尝试做的事情甚至可能在托管时使用窗口服务(显然有IIS托管,我知道这是可能的)

1 个答案:

答案 0 :(得分:1)

这是可能的。我使用WCF服务自我托管制作了一个Windows服务,它在生产环境中运行。 这是我的服务配置部分

<service
          name="WinService.Comunication.ExecutionService" behaviorConfiguration="ExecutionServiceBehavior">
        <endpoint address=""
                  binding="wsHttpBinding"
                  contract="WinService.Comunication.IExecutionService"
                  bindingConfiguration="binding"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <host>
          <baseAddresses>
            <add baseAddress="http://vm-adminHost:11485/ExecutionService"/>
          </baseAddresses>
        </host>
      </service>

工作正常。您的客户端应用必须解析您的服务器名称。