使用 WCF 3.5 和 FlatWsdl EndpointBehavior from Christian Weyer ,我能够在没有任何 <import>
的情况下为我的 WCF 服务获取单个平面 WSDL 文件指令。
现在使用 WCF 4,由于某种原因,这不再起作用。
我已经尝试了很多博客文章中描述的所有内容,包括使用 WcfExtras行为扩展。
他们都指的是Chr。 Weyers 解决方案或推荐 WcfExtras。
我还确保为绑定(bind)、ServiceContract 和 ServiceBehavior 指定了相同的命名空间。
在自定义服务宿主中,当即将注入(inject) FlatWsdlExtension 时,Description.Endpoints 集合始终为空。我尝试使用或不使用地址配置我的服务端点,到目前为止没有运气。
我需要做什么才能为我的 WCF 4 服务获取单个平面 WSDL?
感谢您的任何回答。
最佳答案
我有这个准确 问题。今天经过几次尝试,我终于通过执行以下操作使其工作:
Make sure you specify exactly the same namespace attribute in: ServiceContract, ServiceBehavior, and bindingNamespace (.config->services/service/endpoint section).
Be mindful of this problem, which I did encounter at one point.
Download this zip file and include FlatWsdl/Extensions: FlatWsdl.cs, FlatWsdlServiceHost.cs, and FlatWsdlServiceHostFactory.cs somewhere in your project.
Make sure you specify the fully-qualified classname for your version of FlatWsdlServiceHostFactory.cs (minus .cs of course) in the ServiceHost Factory attribute of your .svc file.
我今天尝试了 WcfExtras 以及其他一些东西——它可能或多或少,但这些步骤最终让我走了。祝你好运!
[编辑]
关于wcf - WCF 4 服务的平面 WSDL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5801128/