I have WCF service with wsDualHttpBinding. How to host it in managed application?
Uri baseAddress = new Uri("http://localhost:51160");
using (ServiceHost host = new ServiceHost(typeof(FileServer), baseAddress))
{
host.Open();
Console.ReadLine();
host.Close();
}
The solution was to add endpoint to my service:
Uri baseAddress = new Uri("http://localhost:51160");
WSDualHttpBinding binding = new WSDualHttpBinding();
using (ServiceHost host = new ServiceHost(typeof(FileServer), baseAddress))
{
host.AddServiceEndpoint(typeof(IFileServer), binding, "http://localhost:51160/FileServer");
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
host.Description.Behaviors.Add(smb);
host.Open();
Console.ReadLine();
host.Close();
}
And the same thing on server side (in config)
<services>
<service name="AK3_Server.FileServer" behaviorConfiguration="FileServerBehavior">
<endpoint address="http://localhost:51160/FileServer" binding="wsDualHttpBinding"
bindingConfiguration="" contract="AK3_Server.IFileServer" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FileServerBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.