我只是在学习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') –