WCFServiceException:找不到必需的属性“绑定”

时间:2010-06-05 18:43:43

标签: wcf exception binding service config

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

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

请帮我解决一下。

干杯, Ravi Santlani

1 个答案:

答案 0 :(得分: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>

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