简体   繁体   English

WCF无法获取元数据

[英]WCF cannot obtain metadata

I'm trying to create a WCF service that can be accessed over HTTP and Named Pipes. 我正在尝试创建可以通过HTTP和命名管道访问的WCF服务。 After changing the default configuration (I added the netNamedPipeBinding and endpoint), I can't consume the WCF service anymore. 更改默认配置(添加了netNamedPipeBinding和终结点)后,我无法再使用WCF服务。 Something has to be wrong with my Web.config. 我的Web.config出了点问题。

Edit: 编辑:

I forgot to post the error I am getting: 我忘记发布我得到的错误:

Error: Cannot obtain Metadata from http://localhost/WebServices/CreateContent.svc 错误:无法从http://localhost/WebServices/CreateContent.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. 如果这是您有权访问的Windows(R)Communication Foundation服务,请检查是否已在指定地址启用了元数据发布。

Web.config Web.config文件

<system.serviceModel>
    <services>
      <service name="Application.WebServices.CreateContent" behaviorConfiguration="behave">
        <endpoint binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"
          name="basicHttp" contract="Application.WebServices.ICreateContent" />
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="mexHttpBinding"
          name="mexHttp" contract="IMetadataExchange" />
        <endpoint binding="netNamedPipeBinding" bindingConfiguration="netNamedPipeBinding"
          name="netNamedPipe" contract="PTUmbraco.WebServices.ICreateContent" />
        <endpoint binding="mexNamedPipeBinding" bindingConfiguration="mexNamedPipeBinding"
          name="mexNamedPipe" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost/WebServices/CreateContent.svc" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="behave">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBinding" maxBufferSize="10485760" maxReceivedMessageSize="10485760" />
      </basicHttpBinding>
      <netNamedPipeBinding>
        <binding name="netNamedPipeBinding" />
      </netNamedPipeBinding>
      <mexHttpBinding>
        <binding name="mexHttpBinding" />
      </mexHttpBinding>
      <mexNamedPipeBinding>
        <binding name="mexNamedPipeBinding" />
      </mexNamedPipeBinding>
    </bindings>
  </system.serviceModel>

I'll try to answer as best as I can, since you didnt post what error you are getting. 我将尽力回答,因为您没有发布遇到的错误。

Did you check if your Net.Pipe Listener Adapter service is up and running? 您是否检查了Net.Pipe侦听器适配器服务是否已启动并正在运行?

在此处输入图片说明

If the error you are getting is "the message could not be dispatched because the service at the endpoint address is unavailable for the protocol of the address", them you might have to use the ServiceModel Registration Tool from microsoft, by running this command on your framework's folder: 如果您收到的错误是“由于终结点地址的服务对于该地址的协议不可用而无法调度该消息”,则您可能必须使用Microsoft的ServiceModel注册工具,方法是在您的计算机上运行此命令框架的文件夹:

C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319>ServiceModelReg.exe -r C:\\ Windows \\ Microsoft.NET \\ Framework64 \\ v4.0.30319> ServiceModelReg.exe -r

I've already had a couple of problems with WCF, and like you, thought it was a config problem, but your config seems to be ok, so you might give those a try. 我已经遇到了WCF的几个问题,并且像您一样,认为这是配置问题,但是您的配置似乎还可以,因此您可以尝试一下。

here's more info about that ServiceModel tool: 这是有关该ServiceModel工具的更多信息:

https://forums.asp.net/t/2039313.aspx?WCF+TCP+Binding+Hosted+in+IIS+7+endpoint+address+is+unavailable+for+the+protocol+of+the+address https://forums.asp.net/t/2039313.aspx?WCF+TCP+Binding+Hosted+in+IIS+7+endpoint+address+is+不可用+ for + the + protocol + of + the + address

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

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