Bonjour,
je travaille actuellement sur un projet C# & WCF.
Je doit utiliser les méthodes de ma ClassLibrary1 depuis le service web WCF.
Voici le code de ma solution :
Solution Test > ClassLibrary 1 > Class1.cs
1 2 3 4 5 6 7 8 9 10 11 12
| using WcfService1;
namespace ClassLibrary1
{
public class Class1 : IService1
{
public string Hello(string who)
{
return "Hello " + who + " from classlibrary1 NOT FROM wcfservice1";
}
}
} |
Solution Test > WcfService1 > IService1.cs
1 2 3 4 5 6 7 8 9
| namespace WcfService1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string Hello(string who);
}
} |
Solution Test > WcfService1 > Service1.svc.cs
1 2 3 4 5 6 7 8 9 10
| namespace WcfService1
{
public class Service1 : IService1
{
public string Hello(string who)
{
return "Hello " + who + " from wcfservice1";
}
}
} |
Solution Test > WcfService1 > Service1.svc
<%@ ServiceHost Language="C#" Debug="true" Service="WcfService1.Service1" CodeBehind="Service1.svc.cs" %>
Solution Test > WcfService1 > Web.config
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration> |
Voilà l'ensemble de mon code !
J'ai lu sur le net que je devais procéder à des changements sur mon code behind ainsi que sur mon web.config mais je ne sais pas quoi faire!
Actuellement quand j'appelle mon service web WCF, je dispose uniquement de la méthode Hello(string) qui me retourn Hello +who+ from wcfservice1, cependant je souhaiterais pouvoir utiliser ma méthode me retournant Hello +who+ from classlibrary1 NOT FROM wcfservice1!
J'espère avoir été suffisamment précis!
Merci d'avance !
Partager