简体   繁体   English

如何为netTcpBinding服务添加服务引用?

[英]How to add service reference for a netTcpBinding service?

Simple problem : 简单问题:

How to self host a netTcpBinding service in client project right clicking Service References > Add Service Reference ... 如何在客户端项目中右键单击“服务参考”>“添加服务参考”以自托管netTcpBinding服务。

Clicking "Discover" it references all services using WsHttpBinding including the netTcpBinding one. 单击“发现”,它将引用所有使用WsHttpBinding的服务,包括netTcpBinding。 But when expanding the netTcpBinding one it can't navigate to the contract and it throw the following error : 但是,在扩展netTcpBinding时,它无法导航至合同,并引发以下错误:

Could not find a base address that matches scheme net.tcp for the endpoint with binding MetadataExchangeTcpBinding. 找不到与绑定MetadataExchangeTcpBinding的终结点计算机的方案net.tcp匹配的基地址。 Registered base address schemes are [http]. 注册的基址方案为[http]。

I found the following .Net WCF sample very nice and neat, but in the example, it doesn't show how the config file is set, and how we could get the proxy via the wizzard. 我发现以下.Net WCF示例非常好且整洁,但是在示例中,它没有显示配置文件的设置方式以及如何通过向导获取代理。

C:\\WF_WCF_Samples\\WCF\\Basic\\Binding\\Net\\Tcp\\Default\\CS C:\\ WF_WCF_Samples \\ WCF \\ Basic \\ Binding \\ Net \\ Tcp \\ Default \\ CS

Here is the service config file ... (I don't use any base adress, it should work without it I think) 这是服务配置文件...(我不使用任何基本地址,如果没有它,它应该可以工作)

   <service behaviorConfiguration="Canopus.WebServices.LogAndNotificationService"
    name="Canopus.WebServices.LogAndNotificationService">      
    <endpoint address="" binding="netTcpBinding"
     contract="Canopus.WebServices.ILogAndNotificationService" />
    <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
   </service>

        <behaviors>
            <serviceBehaviors>
                <behavior name="Canopus.WebServices.LogAndNotificationService">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                </behavior>
            </serviceBehaviors>
        </behaviors>

Thanks for your help ! 谢谢你的帮助 !

I think your service behaviour cannot have httpGetEnabled attribute when ur dealing with netTcPBinding. 我认为当您处理netTcPBinding时,您的服务行为不能具有httpGetEnabled属性。 and also looks like ur end point address contains something like http:// it should be net.tcp://. 并且看起来您的端点地址包含类似http://之类的内容,应该为net.tcp://。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM