WCF REST 服务在 WCFTestClient 中不可见

标签 wcf wcf-rest webhttpbinding wcftestclient

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

 <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 吗?

干杯,
丹妮。

最佳答案

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

这就是短篇小说。如果您想了解更多详细信息,我在 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 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7479187/

相关文章:

wcf - 可以从 SOAP UI 或任何此类工具设置 HTTP Origin 和 Referer 值吗?

wcf - 在其他 Web 服务之上构建 Web 服务是否明智?

windows - 如何将当前 Windows 凭据从使用 JS 制作的 Windows 8 native 应用程序传递到 WCF REST 服务?

c# - 如何使用 WebHttpBinding 在 WCF 的 uri 路径中使用强类型参数

c# - wcf 测试客户端不支持此操作,因为它使用 system.threading.tasks.task

WCF 数据服务和 OData

json - 如何发送 DataContract 对象作为 WCF RESTFUL web 服务的参数?

c# - WCF 休息服务 : How to make query parameters required and return HTTP 400 on wrong values?

.net - webHttpBinding WCF 服务通过 HTTP 响应,但不通过 HTTPS 响应

传递 Null 参数的 WCF 调用