0

我想学习 WCF,所以我决定尝试创建一些使用它的应用程序。那么我想到的是我有 2 个数据库,我还想创建一个 SSIS 自定义数据源扩展,它调用 Web 服务并将数据(从一个数据库)传递到 SSIS ADO.Net 数据源(进入第二个数据库) .

现在我使用 SQL Server 创建了 2 个数据库,每个数据库都有一个表。然后我在 Visual Studio 中添加了一个连接,然后指定了服务器实例。(没有创建任何 .mdf 文件)。我在 Web.Config 文件中添加了这个 connectionString

  <connectionStrings>
    <add name="dbconnection" connectionString=" 
         Data Source = SARE-VAIO;
         Integrated Security = true; 
         Initial Catalog = Database1"/>
  </connectionStrings>

当我编写基本上用数据填充 Database1 的服务时,我想定义端点,但是当我单击“编辑 WCF 配置”时,它显示“未定义服务”?我在这里做错了什么?我想创建一个无错误服务,以便能够将其用作 SSIS 包中的源。

PS。我的服务有一个 basicHttpsBinding

更新:我将 VS 2012 与 .Net Framework 4.5 一起使用

更新 2:我现在跳过了端点定义,继续测试和部署我的 WCF。当我调用该服务时,它说以下错误

  Failed to invoke the service. Possible causes: The service is offline or inaccessible; 
  the client-side configuration does not match the proxy; the existing proxy is invalid. 
  Refer to the stack trace for more detail. You can try to recover by starting a new proxy, 
  restoring to default configuration, or refreshing the service.

这是我的 web.config 文件

  <?xml version="1.0"?>
  <configuration>
    <connectionStrings>
      <add name="dbconnection" connectionString="Data Source = SARE-VAIO; Integrated        Security = true; Initial Catalog = Database1"/>
    </connectionStrings>
    <appSettings>
      <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    </appSettings>
    <system.web>
      <compilation debug="false" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5"/>
    </system.web>
    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior>
            <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
            <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
        </serviceBehaviors>
      </behaviors>
      <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
      </protocolMapping>    
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"       multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true"/>

      <directoryBrowse enabled="true"/>
    </system.webServer>

  </configuration>
4

1 回答 1

0

回答您的问题

(1) 为什么 WCF 配置编辑器显示“未定义服务”错误:您的 web.config 没有明确定义任何服务和端点(注意:当您在 IIS 中托管它时,由于默认端点,您仍然会添加一些端点功能。但配置编辑器工具仅显示明确定义的端点)。这就是配置编辑器工具显示此消息的原因。但是您可以使用该工具来添加服务和端点。

(2) 部署服务后查看服务是否启动成功。您可以通过浏览元数据 URL 来执行此操作(您的配置已启用元数据)。确保您的服务 WSDL 帮助页面和 WSDL 显示正常。如果不先解决这个问题。

(3) 如果您在 IIS 中托管默认 https 端点后正在寻找它,请确保您的 IIS 配置了带有 SSL 证书的 https 绑定。

希望这可以帮助!

谢谢!

于 2012-09-24T19:00:31.200 回答