C#Webservice:接口定义和web.config问题
我正在从事一项网络服务。当我尝试从visualstudio2013启动它时,现在出现以下错误:“未能添加服务。服务元数据可能无法访问。请确保您的服务正在运行并公开元数据。” 有人有潜在的解决方案吗 以下是此Web服务的界面:C#Webservice:接口定义和web.config问题,c#,xml,web-services,C#,Xml,Web Services,我正在从事一项网络服务。当我尝试从visualstudio2013启动它时,现在出现以下错误:“未能添加服务。服务元数据可能无法访问。请确保您的服务正在运行并公开元数据。” 有人有潜在的解决方案吗 以下是此Web服务的界面: namespace WebService { [ServiceContract] interface IWebService { [OperationContract] [WebInvoke(Method = "POST", ResponseFormat =
namespace WebService
{
[ServiceContract]
interface IWebService
{
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "/tasks")]
List<SwitanceTask> getTasks(string groupD, DateTime date);
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/time")]
DateTime getWebServiceTime();
[OperationContract]
[WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/upd")]
int updateTask(SwitanceTask task);
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/grp")]
List<SwitanceGroup> getGroups();
}}
命名空间Web服务
{
[服务合同]
接口IWebService
{
[经营合同]
[WebInvoke(Method=“POST”,ResponseFormat=WebMessageFormat.Xml,
RequestFormat=WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Wrapped,
UriTemplate=“/tasks”)]
列表任务(字符串groupD,DateTime-date);
[经营合同]
[WebInvoke(Method=“GET”,ResponseFormat=WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Bare,
UriTemplate=“/time”)]
DateTime getWebServiceTime();
[经营合同]
[WebInvoke(Method=“POST”,ResponseFormat=WebMessageFormat.Xml,
RequestFormat=WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Bare,
UriTemplate=“/upd”)]
int updateTask(SwitanceTask任务);
[经营合同]
[WebInvoke(Method=“GET”,ResponseFormat=WebMessageFormat.Xml,
BodyStyle=WebMessageBodyStyle.Bare,
UriTemplate=“/grp”)]
列出getGroups();
}}
这是我的配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="baseAdress" value="http://localhost:59074/wse"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1"/>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="metadata" name="WebService.Service">
<endpoint address="/tasks" binding="basicHttpBinding" name="tasks"
contract="WebService.IWebService" />
<endpoint address="/time" binding="basicHttpBinding" name="time"
contract="WebService.IWebService" />
<endpoint address="/upd" binding="basicHttpBinding" name="upd"
contract="WebService.IWebService" />
<endpoint address="/grp" binding="basicHttpBinding" name="grp"
contract="WebService.IWebService" />
<endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:59074/wse" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="metadata">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
您的WCF服务项目是否像在IIS/IIS Express中一样运行?它在IIS Express中运行(visual studio中的默认选项)。是的,我的意思是检查WCF项目是您的解决方案的一部分还是在其他地方单独托管