【问题标题】:WCF REST Service not visible in WCFTestClientWCF REST 服务在 WCFTestClient 中不可见
【发布时间】:2011-11-20 16:57:42
【问题描述】:

我已经成功地为我的原型服务配置了 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 有什么原因吗?

干杯, 丹妮。

【问题讨论】:

  • WCF 测试客户端适用于基于 SOAP 的服务 - 任何 BUT webHttpBinding ....

标签: wcf wcf-rest webhttpbinding wcftestclient


【解决方案1】:

这是因为 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写了一篇关于它的博文

【讨论】:

  • 这是我最初的想法......然后我发现了这个 knowledgebaseworld.blogspot.com/2010/06/… - 这家伙不知何故把它列在了他的 WCFTestClient 上
  • 该端点实际上不能用于使用 JSON(或普通 XML)调用:它没有 &lt;webHttp/&gt; 行为。而且我也尝试了和他完全相同的场景,当我浏览到 WSDL 页面时,我只能看到两个 &lt;wsdl:port&gt; 元素(一个用于基本,一个用于 ws),webHttpBinding 端点没有。跨度>
  • 是的 - 他没有 webHttp 行为,这是我的,因为我需要它与 jQuery.Ajax() 调用交互。
【解决方案2】:

以下是 WCF 测试客户端不支持的功能列表:

• 类型:Stream、Message、XmlElement、XmlAttribute、XmlNode、实现 IXmlSerializableinterface,包括相关的 XmlSchemaProviderAttribute 属性,以及 XDocument 和 XElement 类型以及 ADO.NET DataTable 类型。

• 双工合同。

• 交易。

• 安全性:CardSpace、证书和用户名/密码。

• 绑定:WSFederationbinding、任何上下文绑定和 Https 绑定、WebHttpbinding(Json 响应消息支持)。

来源:http://msdn.microsoft.com/en-us/library/bb552364.aspx

【讨论】:

    【解决方案3】:

    尝试添加公开元数据的“mexHttpBinding”端点

    【讨论】:

    • 这不起作用 - webHttpBinding 端点未在服务元数据中公开。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-01-25
    • 1970-01-01
    • 2011-10-01
    • 2010-09-16
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多