简体   繁体   中英

WCF Service Name & Binding Name

Scenario

I have two WCF Services combined in a single App.Config file. I can't get the thing to run (the application compiles but fails at initialization of the services).

Question

I'm wondering whether I need to set the service name to be the same as something else that is also defined as part of the service overall?

ERROR

TypeInitializationException

{"Service 'MurexUploadObjects.ResponseService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element."}

CODE

<system.serviceModel>
<configuration>

<behaviors>
 <serviceBehaviors>
   <behavior name="Service1Bevhavior">
   </behavior>
   <behavior name="Service2Bevhavior">
   </behavior>
   </serviceBehaviors>
  </behaviors>

   <bindings>
    <netTcpBinding>
      <binding name="tcpBloombergServiceEndPoint" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288"
          maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
       <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
       <reliableSession ordered="true" inactivityTimeout="00:05:00"
      enabled="true" />
       <security mode="None">
       <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
       <message clientCredentialType="Windows" />
       </security>
     </binding>

     <binding name="TransactedBinding">
     <security mode="None" />
     </binding>

   </netTcpBinding>
   </bindings>

 <services>

 <!--SERVICE ONE-->
 <service name="INSERT NAME HERE">
   <endpoint address="net.tcp://AP434190:8732/BloombergService/"
binding="netTcpBinding"
contract="BloomberPriceListenerService.IBloombergPriceListenerService"
bindingConfiguration="tcpBloombergServiceEndPoint"
name="tcpBloombergServiceEndPoint" />
 </service>

 <!--SERVICE TWO-->
 <service name="INSERT NAME HERE">
   <endpoint address="net.tcp://localhost:8735/private/MurexUploadObjects/ResponseService"
               binding="netTcpBinding"
               contract="MurexUploadObjects.IResponseService"
               bindingConfiguration="TransactedBinding"
               name="TransactedBinding"/>
   </service>
 </services>   

</system.serviceModel>  
</configuration>

The service name must be the fully qualified name of your service class, including the namespace, eg

<service name="YourServiceNamespace.YourService"> 

It can't be just anything - the name of the service class is used by ServiceHost to find the right service configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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