将负责连接 Windows Server 上的 SQL Server 的 Web 服务部署到 IIS

将负责连接 Windows Server 上的 SQL Server 的 Web 服务部署到 IIS

在我的公司中,我们在 Windows Server 2008 上设置了一个活动域控制器,并在另一台 Windows 服务器上存储我们的文件并安装 TFS 和 SQL Server,并且我们在一个域上有多台客户端计算机。

我有一个多层 Windows 应用程序,其中一层是包含“AppWebService.asmx”的 Web 服务项目。Web 服务是一组读取/写入位于 Windows Server 2012 上的 SQL Server 的函数。

作为测试,我发布了(文件系统)webservice 项目,获取输出文件并将其存储在我们服务器上的 IIS 中,然后在服务器上安装了 Windows 应用程序,并且它使用发布的 webservice 运行良好。

现在我想在所有域机器上安装 Windows 应用程序并让它们使用位于我们服务器上的 IIS 中的相同 Web 服务,但我一直收到以下错误:

没有端点监听 http://localhost/App/AppWebService.asmx可以接受该消息。这通常是由于地址或 SOAP 操作不正确造成的。

虽然如果在服务器上我浏览“http://localhost/App/AppWebService.asmx“我可以看到其中包含的方法。

这是我的 App.config(在 Windows 应用程序的主项目中):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="App.Properties.Settings.AppConnectionString"
            connectionString="Data Source=PRODUCTION;Initial Catalog=AppDB;User ID=ui;Password=mypassword"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="AppWebServiceSoap" maxReceivedMessageSize="2147483647"/>
            </basicHttpBinding>
        </bindings>
        <client>
        <!--<endpoint address="http://localhost:4550/AppWebService.asmx"
            binding="basicHttpBinding" bindingConfiguration="AppWebServiceSoap"
            contract="com.app.AppWebServiceSoap" name="AppWebServiceSoap" />-->
      <endpoint address="http://localhost/App/AppWebService.asmx"
            binding="basicHttpBinding" bindingConfiguration="AppWebServiceSoap"
            contract="com.app.AppWebServiceSoap" name="AppWebServiceSoap" />
    </client>
    </system.serviceModel>
</configuration>

这是 webservice 项目中的 Web.Config:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

那么我应该怎么做才能使我的应用程序运行并能够从域计算机访问 IIS 上的 Web 服务,以及能够在服务器上执行此操作?(IIS 功能和角色均已启用)

答案1

Localhost 就是本地主机。在服务器上测试时,它可以正常工作,因为服务器通过 localhost 连接到自身。从另一台机器测试时,您需要通过服务器 IP 地址或名称进行连接,而不是通过 localhost。使用 localhost 时,每台机器都会尝试连接到自身,这当然行不通。

相关内容