是露出了WCF服务作为Web服务的.NET 2.0的目标客户时,basicHttpBinding的真正需要?

编程入门 行业动态 更新时间:2024-10-25 03:25:23
本文介绍了是露出了WCF服务作为Web服务的.NET 2.0的目标客户时,basicHttpBinding的真正需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个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的真正需要?

本文发布于:2023-11-15 23:13:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598809.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:目标   客户   露出了   WCF   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!