C# 找不到引用协定的默认终结点元素?

C# 找不到引用协定的默认终结点元素?,c#,web-services,wcf,rest,wcf-rest,C#,Web Services,Wcf,Rest,Wcf Rest,我是WCF服务的初学者。我创建了一个Wcf rest服务。如果我浏览的话,这个很好用 然后我添加了一个新的web应用程序,并添加了该服务的引用。服务已正确加载。但当我检查web.config时,它并没有包含任何关于服务模型的详细信息,它是空的。我实现、构建并运行了解决方案,它会中断并出现以下错误: 找不到引用协定的默认终结点元素 ServiceModel客户端中的“ProductRestService.IPProductRestService” 配置部分。这可能是因为没有配置文件 为应用程序找到

我是
WCF服务的初学者
。我创建了一个Wcf rest服务。如果我浏览的话,这个很好用

然后我添加了一个新的web应用程序,并添加了该服务的引用。服务已正确加载。但当我检查web.config时,它并没有包含任何关于服务模型的详细信息,它是空的。我实现、构建并运行了解决方案,它会中断并出现以下错误:

找不到引用协定的默认终结点元素 ServiceModel客户端中的“ProductRestService.IPProductRestService” 配置部分。这可能是因为没有配置文件 为应用程序找到,或者因为没有匹配的端点元素 可以在client元素中找到此合同

我的服务网络配置如下:

<system.serviceModel>
    <services>
      <service name="WcfService1.ProductRestService"
               behaviorConfiguration="serviceBehavior">
    <endpoint address="ProductRestService" binding="webHttpBinding" contract="WcfService1.IProductRESTService"
              behaviorConfiguration="web"></endpoint>
    </service>
    </services>
      <behaviors>
        <serviceBehaviors>
          <behavior name="serviceBehavior">
            <serviceMetadata httpGetEnabled="true"/>
            <serviceDebug includeExceptionDetailInFaults="false"/>
          </behavior>
        </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

  </system.serviceModel>
客户端web.config为空,如下所示:

<configuration>
    <system.web>
      <compilation debug="true" targetFramework="4.5.1" />
      <httpRuntime targetFramework="4.5.1" />
    </system.web>

</configuration>


如何解决此帮助

在web.config文件中添加以下代码,它将解决此问题

<system.serviceModel>
  <bindings>
    <webHttpBinding>
      <binding name="WebHttpBinding_IProductRESTService" />
    </webHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://{DomainName}/ProductRestService/" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IProductRESTService" contract="WcfService1.IProductRESTService" name="WebHttpBinding_IProductRESTService" />
  </client>
</system.serviceModel>

<system.serviceModel>
  <bindings>
    <webHttpBinding>
      <binding name="WebHttpBinding_IProductRESTService" />
    </webHttpBinding>
  </bindings>
  <client>
    <endpoint address="http://{DomainName}/ProductRestService/" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IProductRESTService" contract="WcfService1.IProductRESTService" name="WebHttpBinding_IProductRESTService" />
  </client>
</system.serviceModel>