WCF design_time_address не отображается в visual studio 2010 - PullRequest
1 голос
/ 08 ноября 2011

В настоящее время у меня есть проект библиотеки сервисов wcf, который включает в себя мой контракт на обслуживание и реализацию.Если я зайду в веб-проект в том же решении, добавлю ссылку на службу и нажму на кнопку обнаружения, я смогу увидеть мою службу в списке http: //..design_time_address/myservice.

Теперь, если бы я пошел дальше и переместил свой контракт на обслуживание и классы реализации в другой проект и настроил мой проект библиотеки wcf так, чтобы он указывал на этот новый проект, я обнаружил, что когда я иду и пытаюсь обнаружитьслужбы в моем веб-приложении, я больше не вижу адрес design_time_address.Это ничего не обнаруживает ..

Вот как выглядел мой app.config для службы wcf до того, как я переместил классы в новый проект

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="Test.Server.Wcf.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/Test.Server.Wcf/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="wsHttpBinding" contract="Test.Server.Wcf.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- 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>

</configuration>

, и вот как он выглядит послеход

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="Test.Server.Core.Service1">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8732/Design_Time_Addresses/Test.Server.Wcf/Service1/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address ="" binding="wsHttpBinding" contract="Test.Server.Core.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- 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>

</configuration>

Что я делаю неправильно?Любая помощь будет принята с благодарностью.Я застрял на этом уже несколько часов и чувствую, что схожу с ума ...

Спасибо

1 Ответ

1 голос
/ 09 ноября 2011

Опция Discover , которую вы используете для добавления справочника услуг, является внутренней визуальной студийной функцией. Что делает, так это запускает и перечисляет сервисы WCF, для которых он может найти реализацию. По какой-то причине он хочет найти реализацию интерфейса службы в типе проекта WCF (библиотека или приложение) с файлом конфигурации. Поэтому, если вы перенесли свою реализацию в основной проект, представляющий собой обычную библиотеку классов без файла app.config, она не будет обнаруживать вашу службу.

Что вы можете сделать, это запустить службу вручную и перейти по URL-адресу, чтобы добавить ссылку на службу. Это просто опция обнаружения, которая больше не работает.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...