我有一个WCF服务,我收留了它在Windows服务。
我尝试添加引用从构建在.NET 2.0中的Windows窗体的客户服务。 ://本地主机:8002 / HBAccess /帮助/ MEX HTTP,但是当我检查Reference.cs ---它只包含一个没有在它的命名空间
现在我添加了basicHttpBinding的和重复相同的步骤:
现在我可以看到类的Web服务。
我的资深同事坚持认为,设置httpGetEnabled为true就足以导出通过http WCF服务,并作出正确的Web引用。
任何人都可以指向我,我在这里失踪了什么?
< system.serviceModel> <服务> <服务behaviorConfiguration =HBAcsNX.HBAccessBehaviorNAME =HBAcsNX.HBAccess> <! - <端点地址=绑定=basicHttpBinding的合同=HBAcsNX.HBAccess/> - > <端点地址=HBAccess绑定=NetTcpBinding的合同=HBAcsNX.HBAccess/> <端点地址=MEX绑定=mexHttpBinding合同=IMetadataExchange接口/> <主机> < baseAddresses> <新增baseAddress =的net.tcp://本地主机:18264 / HBAccess //> <新增baseAddress =HTTP://本地主机:8002 / HBAccess //> < / baseAddresses> < /主机> < /服务> < /服务> <行为> < serviceBehaviors> <行为NAME =HBAcsNX.HBAccessBehavior> < serviceDebug includeExceptionDetailInFaults =真httpHelpPageUrl =HTTP://本地主机:8002 / HBAccess /帮助/> < serviceMetadata httpGetEnabled =真httpGetUrl =HTTP://本地主机:8002 / HBAccess /帮助/ MEX/> < /行为> < / serviceBehaviors> < /行为> < /system.serviceModel>
//致使Reference.cs(空代理存根,只有命名空间)
的#pragma警告禁止1591 命名空间Form.ServiceClient { } 的#pragma警告恢复1591解决方案
问题是 mexHttpBinding 实际上并没有暴露你的服务,它的唯一露出的 defenition 的为您服务的,并且由于.NET 2.0不明白nettcp你会得到一个空的空间,你需要basicHttpBinding的监守这是你的实际服务端点。
如果你看你看,合同mexHttpBinding甚至不是HBAcsNX.HBAccess,而是IMetadataExchange接口的合同。
I have a WCF service and am hosting it in a Windows Service.
I tried to add a reference for the service from a Windows Form client built on .NET 2.0. I could get the Web Reference by pointing to the httpGetUrl="localhost:8002/HBAccess/help/mex" but when I check the Reference.cs---It only contains a namespace with nothing in it.
Now I add the basicHttpBinding and repeat the same steps:
And now I can see the classes for the web service.
My senior colleague insist that setting the httpGetEnabled to true would be sufficient to export the WCF service via http and make a proper web reference.
Could anyone point me to what I am missing here?
<system.serviceModel> <services> <service behaviorConfiguration="HBAcsNX.HBAccessBehavior" name="HBAcsNX.HBAccess"> <!--<endpoint address="" binding="basicHttpBinding" contract="HBAcsNX.HBAccess" />--> <endpoint address="HBAccess" binding="netTcpBinding" contract="HBAcsNX.HBAccess" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="net.tcp://localhost:18264/HBAccess/" /> <add baseAddress="localhost:8002/HBAccess/" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name="HBAcsNX.HBAccessBehavior"> <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageUrl="localhost:8002/HBAccess/help" /> <serviceMetadata httpGetEnabled="true" httpGetUrl="localhost:8002/HBAccess/help/mex" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel>// Resulting Reference.cs (Empty proxy stub with only namespace)
#pragma warning disable 1591 namespace Form.ServiceClient { } #pragma warning restore 1591解决方案
the problem is mexHttpBinding isn't actually exposing your service, its only exposing a defenition of your service, and since 2.0 doesn't understand nettcp you get an empty namespace, you need basicHttpBinding becuase that is your actually service endpoint.
if you look at the contracts you see that the contract for mexHttpBinding isn't even "HBAcsNX.HBAccess" but rather "IMetadataExchange".
更多推荐
是露出了WCF服务作为Web服务的.NET 2.0的目标客户时,basicHttpBinding的真正需要?
发布评论