繁体   English   中英

错误:无法获取元数据

[英]Error: Cannot obtain Metadata

当我将服务部署到测试服务器时,尝试通过wcf测试客户端使用它时出现以下错误(尽管它可以在localhost上运行):

Error: Cannot obtain Metadata from http://internal/RegisterService/RegisterService.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error  
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..HTTP GET Error 

我的web.config看起来像这样:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true"/>
                <etwTracking profileName="EndToEndMonitoring Tracking Profile"/>
            </behavior>
            <behavior name="wsSecureBehavior">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false"/>
    <protocolMapping>
        <add scheme="http" binding="basicHttpBinding"/>
        <add scheme="https" binding="wsHttpBinding"/>
    </protocolMapping>
    <diagnostics etwProviderId="830b12d1-bb5b-4887-aa3f-ab508fd4c8ba">
        <endToEndTracing propagateActivity="true" messageFlowTracing="true"/>
    </diagnostics>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IWcfService" closeTimeout="00:11:00" openTimeout="00:11:00" receiveTimeout="00:10:00" sendTimeout="00:11:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
                    <message clientCredentialType="UserName" algorithmSuite="Default"/>
                </security>
            </binding>
        </basicHttpBinding>
        <wsHttpBinding>
            <binding name="wsHttp_IWcfService" maxBufferPoolSize ="2147483647" maxReceivedMessageSize="2147483647">
                <security mode="Transport">
                    <transport clientCredentialType="None"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <services>
        <service name="Services.WCF.RegisterService" behaviorConfiguration="wsSecureBehavior" >
            <endpoint address="secure" binding="wsHttpBinding" bindingConfiguration="wsHttp_IWcfService" name="registerServiceSecure" contract="Services.WCF.IRegisterService"/>
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWcfService" name="RegisterService" contract="Services.WCF.IRegisterService"/>
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
        </service>
    </services>
</system.serviceModel>

接口:

namespace Services.WCF
{
    [ServiceContract]
    public interface IRegisterService
    {
       ...
    }
}

服务

namespace Services.WCF
{
    public class RegisterService : IRegisterService
    {
        ....
    }       
}

我看过许多帖子,但有相同的错误,但找不到解决方案。 我尝试了以下方法:

  • 确保服务名称在web.config和svc文件中匹配
  • 删除mex绑定
  • 添加基本​​主机
  • 确保Windows / temp文件夹具有iis权限

我可以浏览到该网址,它看起来还可以,但我只是无法通过测试客户端访问它,并且想知道我还可能缺少什么

在进一步浏览了有关该主题的许多帖子之后,我遇到了以下帖子: 错误:无法从http ......?wsdl获取元数据,并尝试了包括远程服务器的自签名证书的选项,这似乎有为我解决了问题。 删除https的绑定也可以

暂无
暂无

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

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