2012-01-26 1 views
0

У меня есть любопытная проблема, когда я пытаюсь подключить службу WCF к приложению WCF. Я получаю ошибки. Отдельно оба компонента WCF работают без сбоев с тестовым клиентом WCF. & Проводка тестирования Winforms, которую я создал.Использование служебной ссылки для связи между сервисом WCF (клиентом) и приложением WCF (сервер)

Вот вызов, который я делаю в службе WCF (клиенте), в ссылку службы, указанную в моем приложении (сервере) WCF.

EventCreationServiceReference.EventCreationServicePortClient _servicereference = 
         new EventCreationServiceReference.EventCreationServicePortClient(); 

Теперь я подключения таким же образом, как это делает тест Harness, единственное различие, которое я могу думать Тест Жгут представляет собой равнину Winforms Применение со ссылками услуг, в то время как это службы WCF разговаривает с Приложение Winforms с интерфейсом WCF.

Ошибка;

Could not find endpoint element with name 'EventCreationApp.IEventCreationServicePort' 
and contract 'EventCreationAppServiceReference.IEventCreationServicePort' in the 
ServiceModel client configuration section. This might be because no configuration file 
was found for your application, or because no endpoint element matching this name could 
be found in the client element. 

Теперь мне было интересно, почему контракт не был найден, поэтому я попытался создать ссылку на службу с указанием ссылки на услугу договора в явной форме, но я был представлен с очень похожей ошибкой.

Uri uri = new Uri("net.tcp://172.26.2.11:8525/EventCreationApp"); 
EndpointAddress endpointAddress = new EndpointAddress(uri); 

EventCreationServiceReference.EventCreationServicePortClient _servicereference = 
new EventCreationAppServiceReference.EventCreationServicePortClient(
"EventCreationAppServiceReference.IEventCreationServicePort", endpointAddress); 

Вот моя конфигурация WCF для приложения WCF;

<system.serviceModel> 
    <bindings> 
     <netTcpBinding> 
     <binding name="EventCreationApp.IEventCreationServicePort" 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:10:00" 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
      <message clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </netTcpBinding> 
    </bindings> 
    <services> 
     <service behaviorConfiguration="EventCreationApp.Service1Behavior" 
     name="EventCreationApp.EventCreationServicePort"> 
     <endpoint address="" binding="netTcpBinding" 
        bindingConfiguration="EventCreationApp.IEventCreationServicePort" 
      contract="EventCreationApp.IEventCreationServicePort" 
      name="EventCreationApp.IEventCreationServicePort"> 
      <identity> 
      <dns value="172.26.2.11" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="net.tcp://172.26.2.11:8525/EventCreationApp" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="EventCreationApp.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="false" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

... и ссылочный код службы обслуживания сервиса WCF для подключения к приложению.

<system.serviceModel> 
     <bindings> 
      <netTcpBinding> 
       <binding name="EventCreationApp.IEventCreationServicePort" 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:10:00" 
         enabled="false" /> 
        <security mode="Transport"> 
         <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" /> 
         <message clientCredentialType="Windows" /> 
        </security> 
       </binding> 
      </netTcpBinding> 
     </bindings> 
     <client> 
      <endpoint address="net.tcp://172.26.2.11:8525/EventCreationApp" 
       binding="netTcpBinding" bindingConfiguration="EventCreationApp.IEventCreationServicePort" 
       contract="EventCreationAppServiceReference.IEventCreationServicePort" 
       name="EventCreationApp.IEventCreationServicePort"> 
       <identity> 
        <dns value="172.26.2.11" /> 
       </identity> 
      </endpoint> 
     </client> 
    </system.serviceModel> 

Помогите, я полностью в тупике.

ответ

0

Не должно ли клиентская конфигурация содержать конечные точки «Клиент»?

WCF Client Configuration

[Редактировать]

Вы говорите, что служба WCF разговаривает с приложением WCF. Разве это не должно быть наоборот?

Или вы говорите, что служба WCF является клиентом, а приложение WCF является сервисом?

+0

Я расширил свой код, чтобы показать код конфигурации клиента. – wonea

+0

Да, я говорю, что я хочу, чтобы служба WCF (клиент) говорила с приложением (сервером) WCF. В основном я занимаюсь архитектурой: я хочу, чтобы службы/приложения WCF могли получать сообщения и отправлять их. – wonea

+0

Только я могу подумать, проверьте конфигурационный файл в папке bin вашего «клиента службы wcf». – chandmk