Error in Protocol Mapping While hosting a WCF service in IIS

[Origin]: http://stackoverflow.com/questions/13123861/error-in-protocol-mapping-while-hosting-a-wcf-service-in-iis

I developed a simple WCF service with VS 2010. And i hosted in the default website in IIS by Adding Application and set the Physical Path

And i tried to browse the .svc file it gives me the following error:

The configuration section ‘protocolMapping’ cannot be read because it is missing a section declaration

Protocol Mapping Error

and I tried many solutions but it doesn’t work

I Created WCF Service Library has an App.config with this:

<?</span><span class="pln">xml version</span><span class="pun">=</span><span class="str">"1.0"</span><span class="pln"> encoding</span><span class="pun">=</span><span class="str">"utf-8"</span> <span class="pun">?></span>
<span class="str"><configuration></span>

  <span class="str"><appSettings></span>
    <span class="pun"><</span><span class="pln">add key</span><span class="pun">=</span><span class="str">"aspnet:UseTaskFriendlySynchronizationContext"</span><span class="pln"> value</span><span class="pun">=</span><span class="str">"true"</span> <span class="pun">/></span>
  <span class="pun"></</span><span class="pln">appSettings</span><span class="pun">></span>
  <span class="pun"><</span><span class="pln">system</span><span class="pun">.</span><span class="pln">web</span><span class="pun">></span>
    <span class="pun"><</span><span class="pln">compilation debug</span><span class="pun">=</span><span class="str">"true"</span> <span class="pun">/></span>
  <span class="pun"></</span><span class="pln">system</span><span class="pun">.</span><span class="pln">web</span><span class="pun">></span>
  <span class="pun"><!--</span> <span class="typ">When</span><span class="pln"> deploying the service library project</span><span class="pun">,</span><span class="pln"> the content of the config file must be added to the host</span><span class="str">'</span><span class="pln">s 
  app</span><span class="pun">.</span><span class="pln">config file</span><span class="pun">.</span> <span class="typ">System</span><span class="pun">.</span><span class="typ">Configuration</span><span class="pln"> does not support config files </span><span class="kwd">for</span><span class="pln"> libraries</span><span class="pun">.</span> <span class="pun">--></span>
  <span class="pun"><</span><span class="pln">system</span><span class="pun">.</span><span class="pln">serviceModel</span><span class="pun">></span>
    <span class="str"><services></span>
      <span class="pun"><</span><span class="pln">service name</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.EvalService"</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">clear </span><span class="pun">/></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"basic"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"basicHttpBinding"</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span><span class="pln">
          listenUriMode</span><span class="pun">=</span><span class="str">"Explicit"</span><span class="pun">></span>
          <span class="str"><identity></span>
            <span class="pun"><</span><span class="pln">dns value</span><span class="pun">=</span><span class="str">"localhost"</span> <span class="pun">/></span>
            <span class="pun"><</span><span class="pln">certificateReference storeName</span><span class="pun">=</span><span class="str">"My"</span><span class="pln"> storeLocation</span><span class="pun">=</span><span class="str">"LocalMachine"</span><span class="pln">
              x509FindType</span><span class="pun">=</span><span class="str">"FindBySubjectDistinguishedName"</span> <span class="pun">/></span>
          <span class="pun"></</span><span class="pln">identity</span><span class="pun">></span>
        <span class="pun"></</span><span class="pln">endpoint</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"mex"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"mexHttpBinding"</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"IMetadataExchange"</span><span class="pln">
          listenUriMode</span><span class="pun">=</span><span class="str">"Explicit"</span><span class="pun">></span>
          <span class="str"><identity></span>
            <span class="pun"><</span><span class="pln">dns value</span><span class="pun">=</span><span class="str">"localhost"</span> <span class="pun">/></span>
            <span class="pun"><</span><span class="pln">certificateReference storeName</span><span class="pun">=</span><span class="str">"My"</span><span class="pln"> storeLocation</span><span class="pun">=</span><span class="str">"LocalMachine"</span><span class="pln">
              x509FindType</span><span class="pun">=</span><span class="str">"FindBySubjectDistinguishedName"</span> <span class="pun">/></span>
          <span class="pun"></</span><span class="pln">identity</span><span class="pun">></span>
        <span class="pun"></</span><span class="pln">endpoint</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"ws"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"wsHttpBinding"</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span><span class="pln">
          listenUriMode</span><span class="pun">=</span><span class="str">"Explicit"</span><span class="pun">></span>
          <span class="str"><identity></span>
            <span class="pun"><</span><span class="pln">dns value</span><span class="pun">=</span><span class="str">"localhost"</span> <span class="pun">/></span>
            <span class="pun"><</span><span class="pln">certificateReference storeName</span><span class="pun">=</span><span class="str">"My"</span><span class="pln"> storeLocation</span><span class="pun">=</span><span class="str">"LocalMachine"</span><span class="pln">
              x509FindType</span><span class="pun">=</span><span class="str">"FindBySubjectDistinguishedName"</span> <span class="pun">/></span>
          <span class="pun"></</span><span class="pln">identity</span><span class="pun">></span>
        <span class="pun"></</span><span class="pln">endpoint</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"net.tcp://localhost:8888/evalservice"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"netTcpBinding"</span><span class="pln">
          contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span><span class="pln"> listenUriMode</span><span class="pun">=</span><span class="str">"Explicit"</span><span class="pun">></span>
          <span class="str"><identity></span>
            <span class="pun"><</span><span class="pln">dns value</span><span class="pun">=</span><span class="str">"localhost"</span> <span class="pun">/></span>
            <span class="pun"><</span><span class="pln">certificateReference storeName</span><span class="pun">=</span><span class="str">"My"</span><span class="pln"> storeLocation</span><span class="pun">=</span><span class="str">"LocalMachine"</span><span class="pln">
              x509FindType</span><span class="pun">=</span><span class="str">"FindBySubjectDistinguishedName"</span> <span class="pun">/></span>
          <span class="pun"></</span><span class="pln">identity</span><span class="pun">></span>
        <span class="pun"></</span><span class="pln">endpoint</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"net.pipe://localhost/evalservice"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"netNamedPipeBinding"</span><span class="pln">
          bindingConfiguration</span><span class="pun">=</span><span class="str">""</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span> <span class="pun">/></span>
        <span class="str"><host></span>
          <span class="str"><baseAddresses></span>
            <span class="pun"><</span><span class="pln">add baseAddress</span><span class="pun">=</span><span class="str">"http://localhost:8080/evalservice"</span> <span class="pun">/></span>
          <span class="pun"></</span><span class="pln">baseAddresses</span><span class="pun">></span>
        <span class="pun"></</span><span class="pln">host</span><span class="pun">></span>
      <span class="pun"></</span><span class="pln">service</span><span class="pun">></span>
    <span class="pun"></</span><span class="pln">services</span><span class="pun">></span>
    <span class="str"><behaviors></span>
      <span class="str"><serviceBehaviors></span>
        <span class="str"><behavior></span>
          <span class="pun"><!--</span> <span class="typ">To</span><span class="pln"> avoid disclosing metadata information</span><span class="pun">,</span> 
          <span class="typ">set</span><span class="pln"> the values below to </span><span class="kwd">false</span><span class="pln"> before deployment </span><span class="pun">--></span>
          <span class="pun"><</span><span class="pln">serviceMetadata httpGetEnabled</span><span class="pun">=</span><span class="str">"True"</span><span class="pln"> httpsGetEnabled</span><span class="pun">=</span><span class="str">"True"</span><span class="pun">/></span>
          <span class="pun"><!--</span> <span class="typ">To</span><span class="pln"> receive exception details </span><span class="kwd">in</span><span class="pln"> faults </span><span class="kwd">for</span><span class="pln"> debugging purposes</span><span class="pun">,</span> 
          <span class="typ">set</span><span class="pln"> the value below to </span><span class="kwd">true</span><span class="pun">.</span>  <span class="typ">Set</span><span class="pln"> to </span><span class="kwd">false</span><span class="pln"> before deployment 
          to avoid disclosing exception information </span><span class="pun">--></span>
          <span class="pun"><</span><span class="pln">serviceDebug includeExceptionDetailInFaults</span><span class="pun">=</span><span class="str">"False"</span> <span class="pun">/></span>
        <span class="pun"></</span><span class="pln">behavior</span><span class="pun">></span>
      <span class="pun"></</span><span class="pln">serviceBehaviors</span><span class="pun">></span>
    <span class="pun"></</span><span class="pln">behaviors</span><span class="pun">></span>
  <span class="pun"></</span><span class="pln">system</span><span class="pun">.</span><span class="pln">serviceModel</span><span class="pun">></span>
<span class="pun"></</span><span class="pln">configuration</span><span class="pun">>

and i Hosted the WCF Service Library application in WCF website (My Client) has an Web.config with this:

<?</span><span class="pln">xml version</span><span class="pun">=</span><span class="str">"1.0"</span><span class="pun">?></span>
<span class="str"><configuration></span>

  <span class="str"><appSettings></span>
    <span class="pun"><</span><span class="pln">add key</span><span class="pun">=</span><span class="str">"aspnet:UseTaskFriendlySynchronizationContext"</span><span class="pln"> value</span><span class="pun">=</span><span class="str">"true"</span> <span class="pun">/></span>
  <span class="pun"></</span><span class="pln">appSettings</span><span class="pun">></span>
  <span class="pun"><</span><span class="pln">system</span><span class="pun">.</span><span class="pln">web</span><span class="pun">></span>
    <span class="pun"><</span><span class="pln">compilation debug</span><span class="pun">=</span><span class="str">"false"</span><span class="pln"> targetFramework</span><span class="pun">=</span><span class="str">"4.5"</span> <span class="pun">/></span>
    <span class="pun"><</span><span class="pln">httpRuntime targetFramework</span><span class="pun">=</span><span class="str">"4.5"</span><span class="pun">/></span>
  <span class="pun"></</span><span class="pln">system</span><span class="pun">.</span><span class="pln">web</span><span class="pun">></span>
  <span class="pun"><</span><span class="pln">system</span><span class="pun">.</span><span class="pln">serviceModel</span><span class="pun">></span>
    <span class="str"><services></span>
      <span class="pun"><</span><span class="pln">service name</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.EvalService"</span><span class="pun">></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">""</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"wsHttpBinding"</span><span class="pln"> bindingConfiguration</span><span class="pun">=</span><span class="str">""</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span> <span class="pun">/></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"mex"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"mexHttpBinding"</span><span class="pln"> bindingConfiguration</span><span class="pun">=</span><span class="str">""</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"IMetadataExchange"</span> <span class="pun">/></span>
        <span class="pun"><</span><span class="pln">endpoint address</span><span class="pun">=</span><span class="str">"basic"</span><span class="pln"> binding</span><span class="pun">=</span><span class="str">"basicHttpBinding"</span><span class="pln"> bindingConfiguration</span><span class="pun">=</span><span class="str">""</span><span class="pln"> contract</span><span class="pun">=</span><span class="str">"EvalServiceLibrary.IEvalService"</span> <span class="pun">/></span>
      <span class="pun"></</span><span class="pln">service</span><span class="pun">></span>
    <span class="pun"></</span><span class="pln">services</span><span class="pun">></span>
    <span class="str"><behaviors></span>
      <span class="str"><serviceBehaviors></span>
        <span class="str"><behavior></span>
          <span class="pun"><!--</span> <span class="typ">To</span><span class="pln"> avoid disclosing metadata information</span><span class="pun">,</span> <span class="typ">set</span><span class="pln"> the values below to </span><span class="kwd">false</span><span class="pln"> before deployment </span><span class="pun">--></span>
          <span class="pun"><</span><span class="pln">serviceMetadata httpGetEnabled</span><span class="pun">=</span><span class="str">"true"</span><span class="pln"> httpsGetEnabled</span><span class="pun">=</span><span class="str">"true"</span><span class="pun">/></span>
          <span class="pun"><!--</span> <span class="typ">To</span><span class="pln"> receive exception details </span><span class="kwd">in</span><span class="pln"> faults </span><span class="kwd">for</span><span class="pln"> debugging purposes</span><span class="pun">,</span> <span class="typ">set</span><span class="pln"> the value below to </span><span class="kwd">true</span><span class="pun">.</span>  <span class="typ">Set</span><span class="pln"> to </span><span class="kwd">false</span><span class="pln"> before deployment to avoid disclosing exception information </span><span class="pun">--></span>
          <span class="pun"><</span><span class="pln">serviceDebug includeExceptionDetailInFaults</span><span class="pun">=</span><span class="str">"false"</span><span class="pun">/></span>
        <span class="pun"></</span><span class="pln">behavior</span><span class="pun">></span>
      <span class="pun"></</span><span class="pln">serviceBehaviors</span><span class="pun">></span>
    <span class="pun"></</span><span class="pln">behaviors</span><span class="pun">></span>
    <span class="str"><protocolMapping></span>
      <span class="pun"><</span><span class="pln">add binding</span><span class="pun">=</span><span class="str">"basicHttpsBinding"</span><span class="pln"> scheme</span><span class="pun">=</span><span class="str">"https"</span> <span class="pun">/></span>
    <span class="pun"></</span><span class="pln">protocolMapping</span><span class="pun">></span>
    <span class="pun"><</span><span class="pln">serviceHostingEnvironment aspNetCompatibilityEnabled</span><span class="pun">=</span><span class="str">"true"</span><span class="pln"> multipleSiteBindingsEnabled</span><span class="pun">=</span><span class="str">"true"</span> <span class="pun">/></span>
  <span class="pun"></</span><span class="pln">system</span><span class="pun">.</span><span class="pln">serviceModel</span><span class="pun">></span>
  <span class="pun"><</span><span class="pln">system</span><span class="pun">.</span><span class="pln">webServer</span><span class="pun">></span>
    <span class="pun"><</span><span class="pln">modules runAllManagedModulesForAllRequests</span><span class="pun">=</span><span class="str">"true"</span><span class="pun">/></span>
    <span class="pun"><!--</span>
        <span class="typ">To</span><span class="pln"> browse web app root directory during debugging</span><span class="pun">,</span> <span class="typ">set</span><span class="pln"> the value below to </span><span class="kwd">true</span><span class="pun">.</span>
        <span class="typ">Set</span><span class="pln"> to </span><span class="kwd">false</span><span class="pln"> before deployment to avoid disclosing web app folder information</span><span class="pun">.</span>
      <span class="pun">--></span>
    <span class="pun"><</span><span class="pln">directoryBrowse enabled</span><span class="pun">=</span><span class="str">"true"</span><span class="pun">/></span>
  <span class="pun"></</span><span class="pln">system</span><span class="pun">.</span><span class="pln">webServer</span><span class="pun">></span>
<span class="pun"></</span><span class="pln">configuration</span><span class="pun">>
shareedit

Amr,

This sounds like you may have permission issues in the folder you .svc is running from, please can you check and see if the following permissions are there:

  • \IIS_IUSERS
  • \IIS_IUSR —If running webservice in Anonymous Mode

For the issue with protocol Mapping, please ensure that the app Pool you are using for the IIS site is setup to use .net 4, as from what I understand protocol mapping is only available in .net 4.

Hope this helps

shareedit
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s