我们在 net.tcp 绑定中有一个 WCF 服务。这个托管在带有 WAS 的 IIS 7 中。该网站的绑定是:http mydns.mysocity.com 80 nt.tcp 8001(没有指定dns)
服务的配置是这样的:
<system.serviceModel>
<client />
<bindings>
<netTcpBinding>
<binding name="netTCP" maxReceivedMessageSize="2147483647" receiveTimeout="06:00:00" >
<security mode="Transport" >
<transport clientCredentialType="Windows" />
<message clientCredentialType="Windows" />
</security>
<reliableSession enabled="true" inactivityTimeout="06:00:00" ordered="true" />
<readerQuotas maxDepth="2000001" maxStringContentLength="2000001"
maxArrayLength="2000001" maxBytesPerRead="2000001" maxNameTableCharCount="2000001" />
</binding>
</netTcpBinding>
<wsDualHttpBinding>
<binding name="dualHttp" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="06:00:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="serviceBehavior">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
<serviceThrottling maxConcurrentCalls="2000" maxConcurrentInstances="2000" maxConcurrentSessions="2000"/>
<dataContractSerializer maxItemsInObjectGraph="96553600" ignoreExtensionDataObject="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="MyService.Services.PublishSubscribeService" behaviorConfiguration="serviceBehavior">
<!--Service de souscription/publication pour les clients qui veulent publier/souscrire et etre notify sur le meme canal. TCP,dualHttp et PoolingDuplex ONLY-->
<endpoint binding="netTcpBinding" bindingConfiguration="netTCP" address="/ITransientPublishSubscribeService/netPublicEndPoint" name="netPublicEndPoint" contract="MyService.Services.Interfaces.ITransientPublishSubscribeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<!--service de publication-->
<endpoint binding="wsDualHttpBinding" bindingConfiguration="dualHttp" address="/IPublishService/wsDualPublicEndPoint" name="wsDualPublicEndPoint" contract="MyService.Services.Interfaces.IPublishService"/>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="mexEndPoint" contract="IMetadataExchange" />
</service>
<endpoint binding="netTcpBinding" bindingConfiguration="netTCP" address="/ITransientGuarantedPublishSubscribeService/netPublicEndPoint" name="netPublicEndPoint" contract="MyService.Services.Interfaces.ITransientGuarantedPublishSubscribeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding" bindingConfiguration="netTCP" address="/ITransientGuarantedSubscribeService/netPublicEndPoint" name="netPublicEndPoint" contract="MyService.Services.Interfaces.ITransientGuarantedSubscribeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding" bindingConfiguration="netTCPNotReliable" address="/ITransientGuarantedPublishSubscribeService/netPublicEndPointNotReliable" name="netPublicEndPointNotReliable" contract="MyService.Services.Interfaces.ITransientGuarantedPublishSubscribeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint binding="netTcpBinding" bindingConfiguration="netTCPNotReliable" address="/ITransientGuarantedSubscribeService/netPublicEndPointNotReliable" name="netPublicEndPointNotReliable" contract="MyService.Services.Interfaces.ITransientGuarantedSubscribeService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" name="mexEndPoint" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
并且 WSDL 包含 MachineName.MySocity.com 作为基地址而不是 mydns.mysocity.com :
<wsdl:port name="netPublicEndPoint" binding="tns:netPublicEndPoint">
<soap12:address location="net.tcp://MachineName.MySocity.com:8001/Services/PublishSubscribeService.svc/ITransientPublishSubscribeService/netPublicEndPoint"/>
<wsa10:EndpointReference>
<wsa10:Address>
net.tcp://MachineName.MySocity.com:8001/Services/PublishSubscribeService.svc/ITransientPublishSubscribeService/netPublicEndPoint
</wsa10:Address>
<Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
<Dns>localhost</Dns>
</Identity>
</wsa10:EndpointReference>
</wsdl:port>
应用程序正在运行,但客户端正在缓存元数据,因此我们必须在更改托管服务器时关闭应用程序。
如何将 WSDL 中的基地址更改为具有 mydns.mysocity.com ?
我已经测试将基地址添加到我的配置中,但它不起作用:
<host>
<baseAddresses>
<add baseAddress="net.tcp://mydns.mysocity.com:8001/Services/PublishSubscribeService.svc"/>
<add baseAddress="http://mydns.mysocity.com/Services/PublishSubscribeService.svc"/>
</baseAddresses>
</host>