0

我正在尝试我的第一个 WCF 服务,因此这可能是一个愚蠢的问题。我创建了一个 WCF 服务,其服务合同为

[ServiceContract]
public interface IAutoComplete
{
    [OperationContract]
    string[] Complete(string str);
}

并实现如下服务:

public class AutoComplete : IAutoComplete
{
    string[] IAutoComplete.Complete(string str)
    {
        DBContext context = new DBContext();
        return context.MVCDemoes.Where(i => i.Name.StartsWith(str)).Select(i => i.Name).ToArray();
    }
}

我在控制台应用程序中托管了我的服务

这是托管配置

<system.serviceModel>
    <services>
      <service name="AutoCompleteService.AutoComplete" behaviorConfiguration="AutocompleteBehavior">
        <endpoint address="AutoComplete" binding="basicHttpBinding" contract="AutoCompleteService.IAutoComplete"></endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/YOUR_ADDRESS/"/>
          </baseAddresses>
        </host>
      </service>

    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="AutocompleteBehavior">
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

我已经开始服务,但是当我转到http://localhost:8732/Design_Time_Addresses/YOUR_ADDRESS/AutoComplete时,我看到了空白页。没有错误,只是一个空白页。可能是什么问题?

4

0 回答 0