views:

41

answers:

1

Hi, My WCF Service when hosted is throwing an error:

WCF Service PayThisException: Required attribute 'binding' not found. (C:\Temp\WCFVirtualDirPath\web.config line 278)

Please help me with some solution.

Cheers, Ravi Santlani

A: 

Show us your web.config !! Especially everything in the <system.serviceModel> section.

If you don't have a web.config file, or your web.config doesn't contain a <system.serviceModel> section - that's your problem right there!

As long as you're not actually showing your real config file, I can only guess what might be wrong. Here's a sample of what a WCF service config should look like:

  <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>

Your message says "binding attribute is missing", so most likely, you didn't specify the ABC of WCF - Address, Binding, Contract on your <endpoint> in your service config.

marc_s
it does contain same. my bionding is wsHttpBinding
@user359349: please update your original post with the <system.serviceModel> section of your web.config - I **cannot** just guess from your few lines what's wrong - I need to **see** the config!
marc_s