gpt4 book ai didi

.net - WCF 服务基地址 Http 和 netTcp

转载 作者:行者123 更新时间:2023-12-04 03:13:58 25 4
gpt4 key购买 nike

我在 WCF 服务配置文件中定义了两个基地址:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Warning, ActivityTracing"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\WCF Service Logs\app_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="DateTime, Timestamp">
<filter type="" />
</add>
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcp" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000">
<readerQuotas maxDepth="500" maxStringContentLength="50000000" maxArrayLength="50000000" maxBytesPerRead="50000000" maxNameTableCharCount="50000000" />
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="ReportingComponentLibrary.TemplateServiceBehavior"
name="ReportingComponentLibrary.TemplateReportService">
<endpoint address="TemplateService" binding="netTcpBinding" bindingConfiguration="netTcp"
contract="ReportingComponentLibrary.ITemplateService"></endpoint>
<endpoint address="ReportService" binding="netTcpBinding" bindingConfiguration="netTcp"
contract="ReportingComponentLibrary.IReportService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8001/TemplateReportService" />
<add baseAddress="http://localhost:8181/TemplateReportService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ReportingComponentLibrary.TemplateServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

虽然我已经将端点绑定(bind)设置为 netTcpBinding,
我只能使用基地址访问我的 WCF 服务:
http://localhost:8181/TemplateReportService

而不是
net.tcp://localhost:8001/TemplateReportService

如何使用 netTcp 地址访问我的服务?

最佳答案

您将 Net.TCP 基地址定义为:

net.tcp://localhost:8001/TemplateReportService

您使用 Net TCP 的端点是:
<endpoint address="TemplateService" 


<endpoint address="ReportService" 

因此,它们的完整服务地址将是“netTcp 基地址”+“ <endpoint> 元素上定义的相对地址” - 这给出:
net.tcp://localhost:8001/TemplateReportService/TemplateService


net.tcp://localhost:8001/TemplateReportService/ReportService

尊敬。

你可以在这些地址使用它们吗?

此外 - 您为 HTTP 协议(protocol)定义了一个“mex”(元数据交换)端点 - 这就是为什么您在导航到 HTTP 地址时可以看到一些东西的原因。但是您没有为 netTcp 指定 MEX 端点。

关于.net - WCF 服务基地址 Http 和 netTcp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2012765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com