简体   繁体   English

错误:无法获取元数据

[英]Error: Cannot obtain Metadata

When I deploy my service to a test server I am getting the following error when I am trying to use it through a wcf test client (although it works under localhost): 当我将服务部署到测试服务器时,尝试通过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 

my web.config looks like this: 我的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>

Interface: 接口:

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

Service 服务

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

I have had a look through many posts with the same error but cannot find a solution. 我看过许多帖子,但有相同的错误,但找不到解决方案。 I have tried the following: 我尝试了以下方法:

  • making sure the name of the service matches in the web.config and svc files 确保服务名称在web.config和svc文件中匹配
  • removing the mex binding 删除mex绑定
  • adding the base host 添加基本​​主机
  • making sure the windows/temp folder has iis permissions 确保Windows / temp文件夹具有iis权限

I can browse to the url and it looks ok but I just can't access it through the test client and was wondering what else I may be missing 我可以浏览到该网址,它看起来还可以,但我只是无法通过测试客户端访问它,并且想知道我还可能缺少什么

After more browsing through the many posts on this subject, I have come across this post: Error: Cannot obtain Metadata from http ......?wsdl and tried the option of including the remote server's self signed certificate and this seems to have solved the problem for me. 在进一步浏览了有关该主题的许多帖子之后,我遇到了以下帖子: 错误:无法从http ......?wsdl获取元数据,并尝试了包括远程服务器的自签名证书的选项,这似乎有为我解决了问题。 Removing the bindings for the https also worked 删除https的绑定也可以

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

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