Expose webHttpBinding endpoint in a WCF service

拈花ヽ惹草 提交于 2019-11-29 06:28:01

@decyclone: I have successfully exposed webHttpBindings without any issue. But I found some interesting thing when it get exposed and when it not!

I can see web binding getting exposed in Wcf Test Client.

Here are my configurations

<services>
  <service behaviorConfiguration="TestWeb.Service2Behavior" name="TestWeb.Service2">
    <endpoint address="" binding="wsHttpBinding" contract="TestWeb.Service2">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="web" binding="webHttpBinding" contract="TestWeb.Service2">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

Point to note here is, its working fine using VS2008 with Framework 3.5, VS2010 with Framework 3.5, when I use VS2010 and Framework 4.0 then I can't see WebHttpBinding getting exposed in WCF Test Client, however I can use that binidng to do http post in all cases.

I assume that in Framework 4.0 its not visible by default, even I try enable endpointDiscovery but still no luck!

I have covered this behaviour in my post

Your "web" endpoint will be exposed as a JSON endpoint. It is not compatible with WSDL.

WebHttpBinding is in System.ServiceModel.Web. If you are using vs2010, go to properties of your project, check target framework. By default it points to .Net Framework 4 Client Profile. It should point to .Net Framework 4, then you can find the System.ServiceModel.Web when you will go to Add reference

@decyclone: One way that a javascript client can learn the available methods on a webHttpBinding is to download a WCF javascript proxy with HTML script tags pointing to your endpoint followed by "/js": <script src="http://localhost/WcfTestService/TestService.svc/web/js"></script>

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!