WCF元数据发布此服务目前已停用+内容类型错误目前、错误、类型、内容

2023-09-02 11:56:09 作者:<十字路口>

这是元数据的错误是我所得到的,当我浏览到在浏览器中的服务。我不与客户消费它

That Metadata error is what I get when I browse to the service in a browser. I am not consuming it with a client

和是的..我说&LT; serviceMetadata httpGetEnabled =真/&GT; ,我有一个MEX端点定义

and Yes.. I added <serviceMetadata httpGetEnabled="True"/>, and I have a mex endpoint defined

但它仍然是行不通的。

所以,我创建了一个准系统服务托管在IIS7。全新安装的Windows 7和VS2010的。

So I created a barebones service to host on IIS7. Fresh install of Windows 7 and VS2010.

我曾跟随这个页面的指示信:

I had followed the instructions of this page to the letter:

http://msdn.microsoft.com/en-us/library/ms733766.aspx

我相信,这必须与IIS7某种配置问题,但并不能确定。这是我的服务设置:

I'm convinced that this has to be some sort of configuration issue with IIS7 but and not sure. Here's my service setup:

编辑:

我试图访​​问与SvcUtil工具的服务,得到了以下错误:

I tried accessing the service with svcutil and got the following 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'..

也说: HTML文档不包含Web服务发现信息

不知道如何解决它,但是......

not sure how to resolve it, however..

.svc文件:

&LT;%@ ServiceHost的语言=C#调试=真正的服务=DestructionServices.TacticalNukeSVC %>

cs文件(位于C:开发 HostedDestructionServices APP_ code文件夹):

.cs file (located in the C:DevelopmentHostedDestructionServicesApp_Code folder):

using System;
using System.ServiceModel;

namespace DestructionServices
{
    [ServiceContract]
    public interface INukeInterface
    {
        [OperationContract]
        string FireMissile();

        [OperationContract]
        string DirectFire(double x, double y, double z);

        [OperationContract]
        void EnterCoordinates(double x, double y, double z);
    }

    public class TacticalNukeSVC : INukeInterface
    {
        public string FireMissile()
        {
            return "Boom";
        }

        public void EnterCoordinates(double x, double y, double z)
        {
            //bah, who cares about coordinates..
        }

        public string DirectFire(double x, double y, double z)
        {
            return "Fired at: " + x + ", " + y + ", " + z;
        }
    }
}

Web.Config中:

Web.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="DestructionServices.Destro" behaviorConfiguration="MetadataBehavior">
        <endpoint address="" binding="wsHttpBinding" contract="DestructionServices.INukeInterface" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetadataBehavior">
          <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

推荐答案

您code和配置似乎不错 - 除了一小点:

Your code and config seems fine - except for one little point:

在你的&LT;服务&GT; 标记,你定义似乎并不符合实际实现服务类的名称:

In your <service> tag, you have defined a name that doesn't seem to correspond to the class that actually implements your service:

<service name="DestructionServices.Destro"  ......>
               ************************** 

但你的类:

namespace DestructionServices
{
    .....
    public class TacticalNukeSVC : INukeInterface
    {

这些名称需要匹配!该名称= 的属性&LT;服务&GT; 在配置标记的必须到底是什么服务类被称为 - 完全合格,其中包括命名空间 - 所以在这里你的情况,应该是:

Those names need to match! The name= attribute on the <service> tag in config must be exactly what your service class is called - fully qualified, including namespace - so in your case here, it should be:

<service name="DestructionServices.TacticalNukeSVC" ......>