c# - WCF 在 IIS 中发布 - 无法获取 wsdl 定义
问题描述
我正在使用 IIS 10 和 Visual Studio 2019。操作系统:Windows 10
我刚刚创建了基本的 wcf 网站(WCF 服务应用程序)。这很简单,只是一个基本的例子。
我试图在调试模式下运行这个项目,使用 IIS express,运行 WcfTestClient。一切都好,wsdl 是从链接消费的:http://localhost:62549/Service1.svc?wsdl
但是,我需要将此服务发布到 IIS。所以,我已经完成了配置发布:
很好,我在 IIS 中看到了新创建的应用程序。
但是现在,我无法得到 wsdl 的定义。链接:http://localhost/WcfService4/Service1.svc?wsdl
我在这里做错了什么?
界面:
using System.ServiceModel;
namespace WcfService4
{
[ServiceContract]
public interface IService1
{
[OperationContract]
string GetData(int value);
}
}
班级:
namespace WcfService4
{
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
}
}
标记:
<%@ ServiceHost Language="C#" Debug="true" Service="WcfService4.Service1" CodeBehind="Service1.svc.cs" %>
网络配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MetadataBehavior" name="WcfService4.Service1">
<endpoint address=""
binding="basicHttpBinding"
contract="WcfService4.IService1" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
解决方案
推荐阅读
- python - 使用 Alexa 查询数据库
- python - Pandas - 以指定格式从 Dataframe 中提取数据
- sql - 在两个表中查找重叠日期范围的出现
- javascript - ViewComponent 不允许操作 DOM
- c# - SQL 组合行以便能够过滤
- nlp - 如何定义多类文本数据集(fastai)的日志计数比?
- java - 如何使用 xml 在 java 中解决 StAX 解析问题?
- python - Django上的破碎图像
- pdftron - 使用 PDFTron WebViewer FormBuilder UI 创建的表单字段的 Javascript 触发操作
- json - jq 将对象转换为数组