添加自定义 ServiceHostFactory 时未找到端点
我创建了一个 wcf 应用程序。我没有改变任何东西。使用Service1.GetData(int)。效果很好。我可以在浏览器中输入 wsdl 等等。然后我创建了一个自定义服务主机工厂,它只返回一个新的服务主机,并且该服务永远不会出现。我无法再在浏览器中访问 wsdl。我尝试添加一个自定义 ServiceHost,这样我就可以进行一些调试,但似乎没有找到端点(即使显式调用 AddDefaultEndpoints() 时也是如此。即使我显式地将端点添加到 web.config 时也是如此。
有人会这样做吗?有任何想法可能是什么问题吗?
如果有人愿意看一下,我将代码放在 github 上: https://github.com/devlife/Sandbox/tree/master/WcfService1
I created a wcf application. I didn't change anything. Used the Service1.GetData(int). It works fine. I can hit the wsdl in a browser and everything. Then I created a custom service host factory that simply returns a new service host and the service never comes up. I can no longer get to the wsdl in a browser. I tried adding a Custom ServiceHost so I could do a little debugging and it appears that there are no endpoints being found (even when explicitly calling AddDefaultEndpoints(). This is true even when I explicitly add the endpoint to the web.config.
Does anyone have any ideas as to what the issue could be?
If anyone cares to take a look I put the code on github: https://github.com/devlife/Sandbox/tree/master/WcfService1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么使用ServiceHostFactory?
您要使用 AppFabric/IIS 吗?或自托管服务?
我认为您需要添加一个 MEX 端点。
Why are you using ServiceHostFactory?
are you going to use AppFabric/IIS? or self hosted services?
I think you need to add a MEX endpoint.
以下是我在我正在处理的项目中定义 CustomHost 的方式,
请
注意,CustomServiceHost 看起来很简单,但这是因为我的解决方案在此 CustomServiceHost 中有大量日志记录和配置,我删除了这些记录和配置,这是不合适的。
我还可以看到的另一个区别是我的 CustomServiceHost 没有添加端点。端点在配置文件中定义如下:
Here is how I have defined a CustomHost in a project I am working on,
And this,
Note that the CustomServiceHost looks bare, but that is because my solution has a lot of logging and configuration in this CustomServiceHost that I removed and is not appropriate.
The other difference I can see also is that my CustomServiceHost does not add the endpoint. The endpoint is defined in the config file like this,