我只是在學習wcf,現在已經有這麼多了。WCF服務主機找不到任何服務元數據
CS文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace wcfLib
{
[ServiceContract]
public interface IfaceService
{
[OperationContract]
int wordLen(string word);
}
public class StockService : IfaceService
{
public int wordLen(string word)
{
return word.Length;
}
}
}
然而,當我試圖運行它,它會彈出一個錯誤:
WCF service host cannot find any service metadata...
任何想法,這可能是什麼?
配置文件:
<system.serviceModel>
<services>
<service behaviorConfiguration="wcfLib.Service1Behavior" name="wcfLib.Service1">
<endpoint address="" binding="wsHttpBinding" contract="wcfLib.ser">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/wcfLib/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="wcfLib.Service1Behavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
您需要向我們展示您的** config **文件!像元數據交換的東西在配置 –
中定義並且您嘗試連接到哪個URL以獲取元數據?你如何主辦這項服務 - IIS或自託管? –
Yoru代碼和配置不匹配 - 代碼中的服務是'wcfLib.StockService',但您的標籤包含'name = wcfLib.Service1' - 這些名稱需要匹配!與端點上的'contract =「wcfLib.ser」'屬性相同 - 需要匹配命名空間+接口名稱! ('wcfLib.IfaceService') –