首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WCF等效于OWIN/Katana内存集成测试

WCF等效于OWIN/Katana内存集成测试
EN

Stack Overflow用户
提问于 2018-09-27 10:05:55
回答 1查看 98关注 0票数 0

对于OWIN/KATANA,内存托管解决方案是可用的: Microsoft.AspNet.WebApi.OwinSelfHost。我想为WCF服务找到类似的方法--可以在内存中运行的集成测试。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-27 10:25:09

这只是自我托管服务吗?

这方面有相当好的文档。

代码语言:javascript
复制
// Create the ServiceHost.
using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress))
{
    // Enable metadata publishing.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
    host.Description.Behaviors.Add(smb);

    // Open the ServiceHost to start listening for messages. Since
    // no endpoints are explicitly configured, the runtime will create
    // one endpoint per base address for each service contract implemented
    // by the service.
    host.Open();

    Console.WriteLine("The service is ready at {0}", baseAddress);
    Console.WriteLine("Press <Enter> to stop the service.");
    Console.ReadLine();

    // Close the ServiceHost.
    host.Close();
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52534492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档