【发布时间】:2020-03-20 14:48:10
【问题描述】:
2020 年 3 月 27 日更新
已经 4 天了,我现在已经填充了办公室的墙壁。 :)
大问题
如果我更改以下设置,这只会在本地工作 匿名身份验证 = 已启用
有谁知道如何解决这个问题 - IIS 快递 - 视觉工作室 2017
我退出了工作代码并在本地创建了一个测试,我现在只卡在一个问题上。
身份验证现在是我的BLOCKER
我需要使用这些设置进行部署,因为我对 DEV 没有任何控制权 |坐 |通用汽车 | PROD --- IAAS 或 PAAS - 我只能编码 CI 和 CD。
我删除了所有的----配置 这不在原始源代码中
我确实必须注释掉
中的代码MultipleBindingServiceHost.cs 文件
本地主机抱怨这 2 个 URL(一旦我修复了代码中的所有安全漏洞,我将重新访问。
string rawUrl = ConfigurationManager.AppSettings["tsRawUrl"];
ServiceEndpoint endpoint = AddServiceEndpoint(typeof(ITicketService), httpBinding, baseAddress, new Uri(rawUrl));
endpoint.Behaviors.Add(new WebHttpBehavior());
#if (!DEBUG)
string vanityUrl = ConfigurationManager.AppSettings["tsVanityUrl"];
ServiceEndpoint endpoint2 = AddServiceEndpoint(typeof(ITicketService), httpBinding, baseAddress, new Uri(vanityUrl));
endpoint2.Behaviors.Add(new WebHttpBehavior());
#endif
2020 年 3 月 23 日
过去一周我一直在尝试了解 WCF 和本地机器的开发,现在我来到 stackoverflow 寻求社区帮助。
我的任务是支持具有两个 WCF 服务的应用程序
Web.config appSettings 设置如下:
<appSettings>
<add key="tsVanityUrl" value="http://localhost:1574/TicketService.svc" />
<add key="tsRawUrl" value="http://localhost:1574/TicketService.svc" />
<add key="fsVanityUrl" value="http://localhost:1574/FileService.svc" />
<add key="fsRawUrl" value="http://localhost:1574/FileService.svc" />
</appSettings>
Web.config system.serviceModel
<system.serviceModel>
<!-- START RBD Additions for Local Development -->
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="TicketBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="FileBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TicketSystem.TicketService" behaviorConfiguration="TicketBehavior">
<endpoint address="/TicketService.svc"
binding="basicHttpBinding"
contract="TicketSystem.ITicketService"
/>
</service>
<service name="TicketSystem.FileService" behaviorConfiguration="FileBehavior">
<endpoint address="/FileService.svc"
binding="basicHttpBinding"
contract="TicketSystem.IFileService"
/>
</service>
</services>
<!-- END RBD Additions for Local Development -->
</system.serviceModel>
我不断收到以下错误:
无法将值添加到集合中,因为集合已包含相同类型的项:“System.ServiceModel.Description.ServiceMetadataBehavior”。此集合仅支持每种类型的一个实例。 参数名称:项目
这将我指向 MultipleBindingServiceHost.cs 文件
protected override void ApplyConfiguration()
{
base.ApplyConfiguration();
ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
Description.Behaviors.Add(mexBehavior);
WebHttpBinding httpBinding = new WebHttpBinding();
foreach (Uri baseAddress in BaseAddresses)
{
if (baseAddress.Scheme == Uri.UriSchemeHttp)
{
httpBinding.Security.Mode = WebHttpSecurityMode.None;
mexBehavior.HttpGetEnabled = true;
}
else if (baseAddress.Scheme == Uri.UriSchemeHttps)
{
httpBinding.Security.Mode = WebHttpSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
mexBehavior.HttpsGetEnabled = true;
}
//ServiceEndpoint endpoint = AddServiceEndpoint(typeof(TicketSystem.ITicketService),
// httpBinding,
// baseAddress);
//endpoint.Behaviors.Add(new WebHttpBehavior());
//Fix for 404 Vanity URL Issue
string rawUrl = ConfigurationManager.AppSettings["tsRawUrl"];
ServiceEndpoint endpoint = AddServiceEndpoint(typeof(ITicketService), httpBinding, baseAddress, new Uri(rawUrl));
endpoint.Behaviors.Add(new WebHttpBehavior());
string vanityUrl = ConfigurationManager.AppSettings["tsVanityUrl"];
ServiceEndpoint endpoint2 = AddServiceEndpoint(typeof(ITicketService), httpBinding, baseAddress, new Uri(vanityUrl));
endpoint2.Behaviors.Add(new WebHttpBehavior());
break;
}
}
}
我知道我非常接近并且可能错过了一些非常简单的东西,但是在花了几天时间之后,我必须在 stackoverflow 上发布以让服务在我的本地机器上运行。
【问题讨论】: