[英]Can't find net.tcp endpoint in add service reference in WCF?
我有WCF和net.tcp绑定的常见问题。 我看到stackoverflow上的所有帖子也谷歌搜索..
我无法向客户端添加服务引用的主要问题。 我收到错误:
Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].
我正在使用IIS 7.我检查了非HTTP.I添加到启用协议net.tcp的网站,还将net.tcp添加到绑定。 如果我点击浏览(http)我的地址。 我看到我的文件夹与WCF应用程序,如果我选择svc文件,我看到正常的地址:
svcutil.exe net.tcp://MYADDRESS/Service.svc/mex
我想如果我看到这个URL我正确设置了我的IIS !!
但是当我尝试添加对客户端的引用时问题就开始了。 只有我看到http端点而没有net.tcp。
这是我的服务配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="MYSERVICE.SERVICE" behaviorConfiguration="behavior1">
<endpoint
binding="netTcpBinding"
contract="MYSERVICE.ISERVICE">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:60745/MYSERVICE/SERVICE/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behavior1">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="netTcpBinding" scheme="net.tcp" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
注意:我的网站从60745地址开始,但是对于IIS中的net.tcp绑定,我添加了60746:*我也打开了两个端口的入站出站规则。
谢谢!
从您在评论中提到的问题来看,我自己也运行它,添加服务引用的gui也不能很好地处理mexTcpBinding
。
您可以将HTTP mex用于元数据,并仍然使用net.tcp作为数据通道。 以下是我的一个使用带有http mex的tcp通道的项目的示例。
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpConfig" closeTimeout="00:30:00" openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00" transferMode="Streamed"
maxReceivedMessageSize="67108864">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="AsyncStreaming">
<dispatcherSynchronization asynchronousSendEnabled="true"/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<serviceCertificate findValue="Example" x509FindType="FindBySubjectName"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Server.Endpoints.ExampleEndpoint">
<endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample"/>
<endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample2"/>
<endpoint address="" behaviorConfiguration="AsyncStreaming" binding="netTcpBinding" bindingConfiguration="NetTcpConfig" contract="Server.IExample3"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<protocolMapping>
<add binding="netTcpBinding" scheme="net.tcp" bindingConfiguration="NetTcpConfig"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<diagnostics wmiProviderEnabled="false">
<messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true"
maxMessagesToLog="3000"/>
</diagnostics>
</system.serviceModel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.