Sar*_*gam 4 wcf wcf-binding webhttpbinding
我创建了一个Web服务,我试图为3个端点提供不同的绑定.1. basicHttpBinding,2.wsHttpBinding,3.webHttpBinding
当我进行服务引用时,我只获得了带有basicHttpBinding和wsHttpBinding绑定的端点.我没有得到webHttpBinding.什么可能是错的.
这是web.config中serviceModel节点的结构.
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"/>
</diagnostics>
<services>
<service behaviorConfiguration="VersionTolerance.Service1Behavior" name="BookShop.BookShopService">
<endpoint address="sadha" binding="basicHttpBinding" contract="BookShop.IBookShopService" />
<endpoint address="ws" binding="wsHttpBinding" contract="BookShop.IBookShopService" >
</endpoint>
<endpoint address="web" binding="webHttpBinding" behaviorConfiguration="webHttpBehavior"
contract="BookShop.IBookShopService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:49654/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="VersionTolerance.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)
mar*_*c_s 10
没有错 - 这就是它的工作方式!
basicHttpBinding
并且wsHttpBinding
是暴露有关其服务的元数据的SOAP绑定 - 您的Visual Studio Add Service Reference
可以查询其端点,找出它们被调用的内容,它们提供的方法,它们期望作为参数的数据类型以及它们返回的内容.
webHttpBinding
是REST - 而REST默认情况下没有元数据的概念 - 你不会得到服务描述,方法列表等等. - REST是关于资源的 - 而不是方法.
因此,当您执行a时 Add Service Reference
,您将获得SOAP端点的代理客户端 - 但不是 REST/webHttpBinding
端点.按设计工作.
WCF数据服务 - 构建在REST之上 - 提供与SOAP绑定类似的体验,因为您可以执行Add Service Reference
并获得一个不错的客户端代理和所有 - 这是因为OData协议在顶部定义了元数据交换REST 因此,如果您可以将REST服务转换为WCF数据服务,那么您可以再次使用.
否则,使用REST,您只需"知道"(从文档页面或其他内容)REST服务的资源URI是什么,以及REST动词在REST上下文中的作用.
归档时间: |
|
查看次数: |
3132 次 |
最近记录: |