WCF TCP端点无法添加服务参考
我在业余时间一直与这个人一起奋斗了几周,决心不转向这个美妙的社区。但我的精神被打破了。所以...WCF TCP端点无法添加服务参考
我已经创建了一个WCF服务,并且试图将其托管在控制台应用程序中,以便使用TCP端点。
我有一个项目,其中包含合同和svc文件。 我有另一个项目,其中包含一个控制台应用程序,它引用了第一个提到的项目。 我的控制台应用程序的主要方法是这样的:
using (ServiceHost host = new ServiceHost(typeof(LicenceBucketWireService.LicenceBucketService)))
{
host.Open();
foreach (var endpt in host.Description.Endpoints)
{
Console.WriteLine("Enpoint address:\t{0}",endpt.Address);
Console.WriteLine("Enpoint binding:\t{0}",endpt.Binding);
Console.WriteLine("Enpoint contract:\t{0}\n", endpt.Contract.ContractType.Name);
}
Console.ReadLine();
}
,不外这一点,一切都是花花公子:
它,当我尝试添加该服务引用就会出差错服务到第三个完全独立的应用程序,它将消耗该服务。当我尝试添加一个参考,使用的net.tcp://本地主机:49189/LicenceBucketWireService/LicenceBucketService/MEX的地址发现的细节,我得到一个错误:
The URI prefix is not recognized. Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'. Metadata contains a reference that cannot be resolved: 'net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService/mex'. If the service is defined in the current solution, try building the solution and adding the service reference again.
控制台应用程序运行时,我执行此任务。 该应用程序的配置具有以下元件:
<system.serviceModel>
<services>
<service name="LicenceBucketWireService.LicenceBucketService">
<clear />
<endpoint address="mex" binding="mexTcpBinding" contract="LicenceBucketWireService.ILicenceBucketService"
listenUriMode="Explicit">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="net.pipe://localhost/licenceBucketService"
binding="netNamedPipeBinding" bindingConfiguration="" contract="LicenceBucketWireService.ILicenceBucketService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:49187/LicenceBucketWireService/LicenceBucketService" />
<add baseAddress="net.tcp://localhost:49189/LicenceBucketWireService/LicenceBucketService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="false" />
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
的代码在配置文件中的下面的行:
<endpoint address="mex" binding="mexTcpBinding" contract="LicenceBucketWireService.ILicenceBucketService"
listenUriMode="Explicit">
应具有合同为“IMetadataExchange接口”,而不是LicenceBucketWireService.ILicenceBucketService。
这应该照顾这个问题。
非常感谢。我太亲近了! – onefootswill 2013-04-05 10:19:06
非常感谢siddharth.It也解决了我的问题。 – 2015-12-22 06:49:47
在服务配置文件中将'httpGetEnabled'属性更改为true。 – 2013-04-04 14:50:26