WCF REST 服务在 WCFTestClient 中不可见 [英] WCF REST Service not visible in WCFTestClient

查看:25
本文介绍了WCF REST 服务在 WCFTestClient 中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为我的原型服务成功配置了 3 个端点.端点是 basicHttpBinding、wsHttpBinding 和 webHttpBinding.我目前唯一的故障是在 WCFTestClient 中.当我将它指向我的服务时,它会列出前两个,但没有列出 webHttpBinding.我可以通过我的浏览器测试 REST 端点,它工作得很好.这是我的配置:

I have successfully configured 3 endpoints for my prototype service. The endpoints are basicHttpBinding, wsHttpBinding, and webHttpBinding. The only glitch I have at the moment is in the WCFTestClient. When I point it to my service it lists the first two, but not the webHttpBinding. I can test the REST endpoint through my browser and it works just fine. Here's my config:

 <system.serviceModel>
    <services>
      <service behaviorConfiguration="serviceBehaviour" name="VMDServices.VMDService">
        <endpoint binding="webHttpBinding"
                  address="rest" behaviorConfiguration="webBehaviour" contract="VMDServices.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint binding="basicHttpBinding"
                  address="basic" bindingConfiguration="basicBinding" contract="VMDServices.IService1">
        </endpoint>
        <endpoint binding="wsHttpBinding"
                  address="ws" bindingConfiguration="wsBinding" contract="VMDServices.IService1">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="basicBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <security mode="None"></security>
          <readerQuotas maxStringContentLength="2147483647"/>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="wsBinding" transactionFlow="true">
          <security mode="None"></security>
          <reliableSession enabled="true" ordered="true" />
        </binding>
      </wsHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="webBehaviour">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="serviceBehaviour">
          <!-- 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>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">
    </serviceHostingEnvironment>
  </system.serviceModel>

为什么我在 WCFTestClient 工具中看不到 webHttpEndpoint?

Is there any reason why I can't see the webHttpEndpoint in the WCFTestClient tool?

干杯,丹妮.

推荐答案

这是因为 Web 端点(与 SOAP 端点不同)不公开元数据,所以测试客户端在下载服务的 WSDL 时并不知道它.与具有用于公开元数据(WSDL、MEX)的明确定义格式的 SOAP 不同,Web(也称为 REST)端点没有.

It's because web endpoints (unlike SOAP ones) do not expose metadata, so the test client doesn't know about it when it downloads the WSDL for the service. Unlike SOAP, which has well-defined formats for exposing metadata (WSDL, MEX), web (a.k.a. REST) endpoints do not.

这就是短篇小说.如果你想了解更多细节,我在 http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-aka-rest-endpoint-does-not-work.aspx

That's the short story. If you want to know more details, I wrote a blog post about it at http://blogs.msdn.com/b/carlosfigueira/archive/2012/03/26/mixing-add-service-reference-and-wcf-web-http-a-k-a-rest-endpoint-does-not-work.aspx

这篇关于WCF REST 服务在 WCFTestClient 中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆