【问题标题】:WCFServiceException: Required attribute 'binding' not foundWCFServiceException:找不到所需的属性“绑定”
【发布时间】:2011-02-28 05:21:26
【问题描述】:

托管时我的 WCF 服务抛出错误:

WCF 服务 PayThisException:找不到必需的属性“绑定”。 (C:\Temp\WCFVirtualDirPath\web.config 第 278 行)

请帮我解决一下。

干杯, 拉维·桑特拉尼

【问题讨论】:

    标签: wcf exception binding service config


    【解决方案1】:

    向我们展示您的 web.config !!尤其是 <system.serviceModel> 部分中的所有内容。

    如果您没有web.config 文件,或者您的web.config 不包含<system.serviceModel> 部分 - 那就是您的问题!

    只要你没有真正显示你的真实配置文件,我只能猜测可能出了什么问题。以下是 WCF 服务配置的示例:

      <system.serviceModel>
        <services>
          <service name="WCFBindings.Service1" 
                   behaviorConfiguration="ServiceBehavior1">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:7876/YourService/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address 
                 supplied above -->
            <endpoint 
                 address="" 
                 binding="wsHttpBinding" 
                 contract="WCFBindings.IService1">
               <!-- 
                  Upon deployment, the following identity element should be 
                  removed or replaced to reflect the identity under which the 
                  deployed service runs. If removed, WCF will infer an 
                  appropriate identity automatically.
               -->
               <identity>
                  <dns value="localhost"/>
               </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to 
                 describe itself to clients. --> 
            <!-- This endpoint does not use a secure binding and should be 
                 secured or removed before deployment -->
            <endpoint 
                 address="mex" 
                 binding="mexHttpBinding" 
                 contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehavior1">
              <!-- To avoid disclosing metadata information, set the value 
                   below to false and remove the metadata endpoint above 
                   before deployment -->
              <serviceMetadata httpGetEnabled="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>
      </system.serviceModel>
    

    您的消息显示“缺少绑定属性”,因此很可能您没有在服务配置中的 &lt;endpoint&gt; 上指定 ABC of WCF - 地址、绑定、合同。

    【讨论】:

    • 它确实包含相同的内容。我的绑定是 wsHttpBinding
    • @user359349:请使用 web.config 的 部分更新您的原始帖子 - 我无法从你的几行中猜测出了什么问题 - 我需要查看配置!
    猜你喜欢
    • 1970-01-01
    • 2022-12-18
    • 2011-09-14
    • 1970-01-01
    • 1970-01-01
    • 2020-04-19
    • 2021-03-11
    • 2017-04-28
    • 1970-01-01
    相关资源
    最近更新 更多