Create the Service Configuration as:
<system.serviceModel>
<services>
<service behaviorConfiguration="DefaultBehaviour"
name="DocumentManagementService.SharePointToSQL">
<endpoint address=""
binding="netTcpBinding" name="docManagementService"
contract="DocumentManagementService.ISharePointToSQL" />
<endpoint address="/mex"
binding="mexTcpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1/DocManagementService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehaviour">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://127.0.0.1" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
and to Host It:
using (ServiceHost serviceHost = new ServiceHost(typeof(SharePointToSQL)))
{
serviceHost.Open();
foreach (var endPoints in serviceHost.Description.Endpoints)
{
Console.WriteLine(endPoints.Address);
}
}
I am able to see the endpoint address while hosting the application through console:
But when I am trying to add the service using wcftestclient , getting the error:
Error:
Cannot obtain Metadata from net.tcp://127.0.0.1/DocManagementService/mex If this
is a Windows (R) Communication Foundation service to which you have access,
please check that you have enabled metadata publishing at the specified address.