我在瀏覽器中瀏覽服務時收到元數據錯誤。我不與客戶WCF當前禁用此服務的元數據發佈+內容類型錯誤
和Yes。我加入<serviceMetadata httpGetEnabled="True"/>
消費它,我有一個MEX終結定義
,但它仍然不會工作..
所以我創建了一個準系統服務在IIS7上託管。全新安裝Windows 7和VS2010。
我採納了這個頁面的指示信:
http://msdn.microsoft.com/en-us/library/ms733766.aspx
我相信,這已經是某種配置問題與IIS7,但並不能確定。這是我的服務設置:
編輯:
我試圖訪問與SvcUtil工具的服務,得到了以下錯誤:
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'..
,它也說:The HTML document does not contain Web service discovery information.
不知道如何解決它,但是..
.svc文件:
<%@ServiceHost language="C#" Debug="true" Service="DestructionServices.TacticalNukeSVC
「%>
cs文件(位於C:\發展\ HostedDestructionServices \ App_Code文件夾):
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中:
<?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>
也加入了baseAddress節點得到由IIS – KevinDeus 2011-02-07 03:09:02
是的,如果你在IIS託管,指定的基址是沒有實際意義的,因爲IIS將忽略決定你的服務在哪裏... – 2011-02-07 06:05:32