简体   繁体   English

WCF服务中缺少元数据

[英]Missing MetaData In WCF Service

I am running into an issue where my WCF REST service does not seem to have metadata. 我遇到了一个问题,其中WCF REST服务似乎没有元数据。 This prevents me from using the WCF Test Client. 这使我无法使用WCF测试客户端。

The rest of the service appears to build and generate the service definitions correctly. 服务的其余部分似乎可以正确构建和生成服务定义。 Here is my web.config. 这是我的web.config。 What am I missing here? 我在这里想念什么? Any constructive input would be greatly appreciated. 任何建设性的投入将不胜感激。

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

WCF REST services doesn't use metadata, it's available for SOAP only. WCF REST服务不使用元数据,仅适用于SOAP。 Try to use fiddler or other similar tool as a test client 尝试使用提琴手或其他类似工具作为测试客户端

I had exactly the same problem - having never used WCF Test tool before I was completely stumped. 我遇到了完全相同的问题-在完全陷入困境之前从未使用过WCF测试工具。

I found the following answer from Carlos Figueira very insightful: 我发现Carlos Figueira的以下答案非常有见地:

This is a limitation of the web programming model itself. 这是Web编程模型本身的限制。 Unlike SOAP endpoints (ie, those with BasicHttpBinding, WSHttpBinding, etc) which have a way to expose metadata about itself (WSDL or Mex) with information about all the operations / parameters in the endpoint, there's currently no standard way to expose metadata for a non-SOAP endpoint - and that's exactly what the webHttpBinding-based endpoints are. 与SOAP端点(即具有BasicHttpBinding,WSHttpBinding等的端点)可以通过端点中有关所有操作/参数的信息公开有关其自身的元数据(WSDL或Mex)的方法不同,目前没有标准的方法可以公开非SOAP端点-正是基于webHttpBinding的端点。 In short, the WCF Test Client won't be useful for web-based endpoints. 简而言之,WCF测试客户端对基于Web的端点将无用。 If some standard for representing web-style endpoints emerges when WCF ships its next version, we'll likely update the test client to support it, but for now there's none widely adopted. 如果在WCF的下一个版本发布某种表示Web样式终结点的标准时,我们可能会更新测试客户端以支持它,但是目前还没有被广泛采用。

Read more at WCF Test Client and WebHttpBinding WCF测试客户端和WebHttpBinding中阅读更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM