具有 WCF 服务的 WPF 客户端,从本地主机开发到生产服务器

本文关键字:开发 主机 服务器 服务 WCF WPF 客户端 具有 | 更新日期: 2023-09-27 18:30:18

我刚刚开始学习WCF。我已成功使用主机控制台应用程序设置 WCF 服务。该服务映射到具有实体框架的 SQL Server。然后,我有一个使用该服务的 WPF 客户端应用程序。这一切都在 Dev 中运行良好,从我的机器运行的服务和客户端应用程序:

<endpoint address="http://localhost:8081/" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
    name="BasicHttpBinding_IRegimesService" />    

现在,我已将服务和主机转移到新 VM 上。服务主机运行正常。我现在正在尝试配置客户端应用终结点以连接到服务。我认为HTTP地址不正确:

服务应用配置:

  <services>
   <service name="diiRegimesService.RegimesService">
    <endpoint address="" binding="basicHttpBinding" contract="diiRegimesService.IRegimesService"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8082" />
      </baseAddresses>
    </host>
  </service>
</services>

客户端应用配置:

<client>
  <endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_IRegimesService" contract="RegimesService.IRegimesService"
    name="BasicHttpBinding_IRegimesService" />
</client>

远程桌面的服务器凭据为:emea-myserver01.emea.basketballinfo.com我目前没有在我的客户端app.config中指定用户名和密码。

该服务正在服务器上运行。我在尝试在客户端应用程序中添加服务引用时遇到异常。

添加服务参考 - 地址: http://EMEA-myserver01.emea.basketballinfo.com

The request failed with HTTP status 404: Not Found.
Metadata contains a reference that cannot be resolved: 'http://emea-myserver01.emea.basketballinfo.com/'.

具有 WCF 服务的 WPF 客户端,从本地主机开发到生产服务器

您需要确保服务器能够解析完整的域名。

此外,客户端配置代码段<endpoint address="http://emea-myserver01.emea.basketballinfo.com/localhost:8082/中提供的地址 URL 似乎无效。 也许你想使用<endpoint address="http://emea-myserver01.emea.basketballinfo.com:8082/