【问题标题】:Missing MetaData In WCF ServiceWCF 服务中缺少元数据
【发布时间】:2017-07-27 21:36:12
【问题描述】:

我遇到了一个问题,我的 WCF REST 服务似乎没有元数据。这使我无法使用 WCF 测试客户端。

服务的其余部分似乎可以正确构建和生成服务定义。这是我的 web.config。我在这里想念什么?任何建设性的意见将不胜感激。

<?xml version="1.0"?>
<configuration>
    <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    </appSettings>
    <connectionStrings>
        <clear />
        <add name="Requests" connectionString="REMOVED" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5"/>
    </system.web>
    <system.serviceModel>
        <services>
            <service name="Requests.Requests" behaviorConfiguration="ServiceBehavior">
                <endpoint address="" binding="webHttpBinding" contract="Requests.IRequests" bindingConfiguration="WebBinding" behaviorConfiguration="EndpointBehavior" />
            </service>
        </services>
        <bindings>
            <webHttpBinding>
                <binding name="WebBinding">
                    <security mode="None" />
                </binding>
            </webHttpBinding>
        </bindings>
        <behaviors>
            <endpointBehaviors>
                <behavior name="EndpointBehavior">
                    <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" />
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <directoryBrowse enabled="true"/>
    </system.webServer>
</configuration>

【问题讨论】:

    标签: c# wcf rest web-config


    【解决方案1】:

    WCF REST 服务不使用元数据,它仅适用于 SOAP。尝试使用fiddler或其他类似工具作为测试客户端

    【讨论】:

      【解决方案2】:

      我遇到了完全相同的问题 - 在我完全被难住之前从未使用过 WCF 测试工具。

      我发现 Carlos Figueira 的以下回答很有见地:

      这是网络编程模型本身的限制。不同于 SOAP 端点(即具有 BasicHttpBinding、WSHttpBinding 等的端点) 有一种方法可以公开关于自身的元数据(WSDL 或 Mex) 有关端点中所有操作/参数的信息, 目前没有标准方法来公开非 SOAP 的元数据 端点——这正是基于 webHttpBinding 的端点 是。简而言之,WCF 测试客户端对于基于 Web 的 端点。如果有一些表示 web 样式端点的标准 当 WCF 发布下一个版本时出现,我们可能会更新测试 客户端支持它,但目前还没有被广泛采用。

      阅读更多WCF Test Client and WebHttpBinding

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-07-14
        • 2015-11-15
        • 1970-01-01
        • 2016-04-10
        • 1970-01-01
        相关资源
        最近更新 更多