WCF HTTP and NamedPipe service

萝らか妹 提交于 2019-12-23 04:03:42

问题


I'm creating a WCF service which, at the moment, exposing a number of contracts using a basicHttpBinding. However, I now want to use the service locally on the same machine, and a netNamedPipeBinding seems more appropriate in terms of performance. For that reason, I want to expose the service using a named pipe and HTTP.

At the moment I'm doing this with the following configuration:

<service name="WCFService.MyService" behaviorConfiguration="serviceBehaviour">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/MyService" />
        <add baseAddress="net.pipe://localhost/MyService" />
      </baseAddresses>
    </host>

    <endpoint address="calculator" binding="basicHttpBinding" contract="WCFService.ICalculatorService" />
    <endpoint address="database" binding="basicHttpBinding" contract="WCFService.IDatabaseService" />
</service>

This appears to work fine, but on closer inspection the endpoints are still using the basicHttpBinding. This works, but I get the impression it's creating unnecessary overhead.

Do I need to create an endpoint for each contract, and each binding type (i.e. basicHttpBinding and netNamedPipeBinding) or am I going about this completely wrong?

(If it's not clear, I'm fairly new to WCF!)


回答1:


Yes, you need to specify multiple endpoints (1 endpoint per binding):

<endpoint address="calculator" binding="basicHttpBinding" contract="WCFService.ICalculatorService" />
<endpoint address="database" binding="basicHttpBinding" contract="WCFService.IDatabaseService" />

<endpoint address="calculator" binding="netNamedPipeBinding" contract="WCFService.ICalculatorService" />
<endpoint address="database" binding="netNamedPipeBinding" contract="WCFService.IDatabaseService" />


来源:https://stackoverflow.com/questions/4484953/wcf-http-and-namedpipe-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!