Skip to content

Instantly share code, notes, and snippets.

@abelsilva
Created December 9, 2016 20:13
Show Gist options
  • Save abelsilva/ac4ae0aeaf90c93adf0dcbaa6dca8cfa to your computer and use it in GitHub Desktop.
Save abelsilva/ac4ae0aeaf90c93adf0dcbaa6dca8cfa to your computer and use it in GitHub Desktop.
swaggerwcf self host
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.serviceModel>
<services>
<service name="SwaggerWcf.Test.Service.BookStore" behaviorConfiguration="bookStoreBehavior">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8088/books"/>
</baseAddresses>
</host>
<endpoint address="http://localhost:8088/books" binding="basicHttpBinding" contract="SwaggerWcf.Test.Service.IStore"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
<service name="SwaggerWcf.SwaggerWcfEndpoint" behaviorConfiguration="swaggerBehavior">
<endpoint address="http://localhost:8088/api-docs" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="bookStoreBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="swaggerBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
using System.ServiceModel.Web;
using SwaggerWcf.Test.Service;
namespace SwaggerWcf.Test.Console
{
internal class Program
{
private static void Main()
{
WebServiceHost booksHost = new WebServiceHost(typeof(BookStore));
booksHost.Open();
WebServiceHost swaggerHost = new WebServiceHost(typeof(SwaggerWcfEndpoint));
swaggerHost.Open();
System.Console.WriteLine("Press [ENTER] to terminate");
System.Console.ReadLine();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment