Create the svc file

  • In the directory that hosts the WCF service (in the example " C: \ inetpub \ wwwroot \ wss \ VirtualDirectories \ 80 \ _wcf ")
    create a file with the (. svc) extension and another Web.config file.
  • Edit the file as following (replace words between two $ by appropriate values):
<%@ Assembly Name="$Nom de votre Assembly$, Version=1.0.0.0, Culture=neutral, PublicKeyToken=$PKT de votre assembly$"%> 
<% @ServiceHost Service="$namespace$.$classe implementant le service$" %>
  • Edit the web.config file as well (replace words between two $ by appropriate values, the parameters $ 1, $ 2, $ 3, $ 4 ... are free but must match):
<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.serviceModel>
    <services>
      <service behaviorConfiguration="$1" name="$namespace$.$classe implementant le service$">
        <endpoint address="" binding="wsHttpBinding" contract="$namespace$.$Interface definissant le service$">
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <endpoint address="REST" binding="webHttpBinding" contract="$namespace$.$Interface definissant le service$" behaviorConfiguration="$2" />
        <host>
          <baseAddresses>
            <add baseAddress="http://$adresse de votre site SharePoint$/_wcf/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="$1">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="$2">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
</configuration>

Also available in: HTML TXT