我在网上搜索过,但找不到解决问题的方法。
我使用 nettcpbinding 在 XP 上自行托管我的服务。配置文件如下:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<services>
<service behaviorConfiguration="behaviorconfig"
name="myservice">
<host>
<baseAddresses>
<add baseAddress="net.tcp://10.1.3.186:8001/myService" />
</baseAddresses>
</host>
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="BindingConfiguration"
contract="xxx.ISomeService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="BindingConfiguration" receiveTimeout="10:00:00"
sendTimeout="10:00:00" maxBufferSize="65536" maxReceivedMessageSize="65536"
transferMode="Streamed">
<readerQuotas maxDepth="65536" maxStringContentLength="65536"
maxArrayLength="65536" maxBytesPerRead="97108864" maxNameTableCharCount="65536" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorconfig">
<serviceMetadata />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
并且 selfhost 代码是
Uri tcpUrl = new Uri("net.tcp://10.1.3.186:8001/myService");
//Create ServiceHost
ServiceHost host
= new ServiceHost(typeof(xxx.SomeService), tcpUrl);
//Add a service endpoint
host.AddServiceEndpoint(typeof(xxx.ISomeService)
, new NetTcpBinding(), "");
//Enable metadata exchange
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = false;
host.Description.Behaviors.Add(smb);
//Start the Service
host.Open();
当我尝试添加服务引用时,我收到错误错误:无法从 net.tcp://10.1.3.186:8001/myService/mex 获取元数据
这里有什么问题?