I followed this tutorial to deploy a custom WCF: https://nikpatel.net/2012/02/29/step-by-step-building-custom-wcf-services-hosted-in-sharepoint-part-i/
And it's worked, but now I'm trying to deploy it in my current solution, when I deployed my sharepoint solution, I have the following error message:
The type 'Test.PS2010.WCF.PSIExtension.Service, Test.PS2010.WCF.PSIExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6e6682caac50df24', provided as the Service attribute value in the ServiceHost directive could not be found.
So in my solution, I have my PSIExtension(Test.PS2010.WCF.PSIExtension), and my sharepoint Solution(Test.PS2010.WCF), my Psiextension containts the following files:
A webconfig file:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="extensionBasicHttpConf"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="true"
maxBufferSize="4194304"
maxReceivedMessageSize="500000000"
messageEncoding="Text"
transferMode="StreamedResponse">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" realm="" />
</security>
</binding>
<binding name="mexHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" realm="" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="PSIExtensionServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Test.PS2010.WCF.PSIExtension.Service"
behaviorConfiguration="PSIExtensionServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="extensionBasicHttpConf"
contract="Test.PS2010.WCF.PSIExtension.IService" />
<endpoint address="mex"
binding="basicHttpBinding"
bindingConfiguration="mexHttpBinding"
name="mex"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
</configuration>
My Iservice.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.Data;
using System.Xml;
namespace Test.PS2010.WCF.PSIExtension
{
[ServiceContract]
internal interface IService
{
[OperationContract]
bool isAlive(out string m_strError);
}
}
and my service:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;
using System.Web;
using System.Xml;
using System.Data;
using System.Reflection;
using System.Configuration;
namespace Test.PS2010.WCF.PSIExtension
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service : IService
{
private static HttpContext c_objContext;
private static string l_strNameSpace;
private static string l_strTypeName;
public Service()
{
l_strNameSpace = this.GetType().Namespace;
l_strTypeName = this.GetType().Name;
c_objContext = HttpContext.Current;
}
public bool isAlive(out string m_strMessage)
{
m_strMessage = "Alive and Kicking ('" + getDbConnectionString() + "')";
return (true);
}
private static Uri getServiceUri()
{
var l_objRequestUri = c_objContext.Request.Url;
int l_intPortNum = 80;
var l_objPortString = l_objRequestUri.GetComponents(UriComponents.Port, UriFormat.SafeUnescaped);
if (!string.IsNullOrEmpty(l_objPortString))
{
l_intPortNum = int.Parse(l_objPortString);
}
var l_objUriBuilder = new UriBuilder(l_objRequestUri.GetComponents(UriComponents.Scheme, UriFormat.SafeUnescaped),
l_objRequestUri.GetComponents(UriComponents.Host, UriFormat.SafeUnescaped),
l_intPortNum,
c_objContext.Request.RawUrl);
return (l_objUriBuilder.Uri);
}
private static string getDbConnectionString()
{
string l_strUrl = null;
try
{
l_strUrl = getServiceUri().ToString();
l_strUrl = l_strUrl.Replace("http://", "");
l_strUrl = l_strUrl.Replace("https://", "");
l_strUrl = l_strUrl.Replace("/_vti_bin/psi/Test.PS2010.Fruit.PSIExtension.svc", "");
return (ConfigurationManager.AppSettings[l_strUrl + "_PSCustom_ConnectionString"]);
}
catch (Exception e)
{
return (e.Message + " (" + l_strUrl + ")");
}
}
}
}
and in my sharepoint solution, I have in the following folders ISAPI ==> PSI ==>Test.PS2010.WCF.PSIExtension.svc :
<%@ServiceHost language="c#" Service="Test.PS2010.WCF.PSIExtension.Service, Test.PS2010.WCF.PSIExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=663d2f95b0755e1f" %>
I don't know why I have this message, I made some searches on the boards but I tried all the solutions that people suggested but nothing works in my case any idea of why?