Не удалось найти элемент конечной точки по умолчанию, который ссылается на исключение контракта при использовании WCF - PullRequest
0 голосов
/ 14 марта 2012

Я создал WCF, который позже преобразовал в SSL (HTTPS) Для чего я сделал некоторые изменения в веб-конфигурации.

Я могу просмотреть этот сервис, а также получить wsdl для сервиса.

Я получаю правильный ответ от службы при обращении с использованием класса HTTPWebrequest.

Позже я добавил этот сервис как сервис Refrence с именем NestleServiceRef. При создании объекта по этой ссылке используется

 NestleServiceRef.NestleMiddlewareClient nestle = new NestleServiceRef.NestleMiddlewareClient();

я получаю это исключение:

System.InvalidOperationException: Could not find default endpoint element that references contract 'NestleServiceRef.INestleMiddleware' 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 contract could be found in the client element.
   at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Configuration configuration)
   at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
   at System.ServiceModel.ClientBase`1..ctor()
   at WebApplication1.NestleServiceRef.NestleMiddlewareClient..ctor() in C:\Users\461167\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Service References\NestleServiceRef\Reference.cs:line 221
   at WebApplication1._Default.Button2_Click(Object sender, EventArgs e) in C:\Users\461167\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Default.aspx.cs:line 29}

Мой файл Web.config:

 <?xml version="1.0"?>
    <configuration>
      <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
          <section name="NestleMiddlewareWCF.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
      </configSections>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
        <membership>
          <providers>
            <clear />
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" passwordFormat="Clear" connectionStringName="SQLConnectionString1" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
          </providers>
        </membership>
      </system.web>
      <appSettings>
        <add key="sqliteTemplateName" value="D:\\NestleSQLite\\NestleSqliteTemplate.sqlite" />
        <add key="sqliteFileName" value="D:\\NestleSQLite\\NestleSqliteFile.sqlite" />
        <add key="sqliteConnection" value="Data Source=D:\NestleSQLite\NestleSqliteFile.sqlite;Version=3;New=false;Compress=True" />
        <add key="masterSqliteConnection" value="Data Source=D:\NestleSQLite\NestleSqliteTemplate.sqlite;Version=3;New=false;Compress=True" />
      </appSettings>
      <connectionStrings>
        <add name="SQLConnectionString" connectionString="server=01HW361477;user id=sa;password=DBP@ss;database=IK" />
        <add name="SQLConnectionString1" connectionString="server=01HW361477;user id=sa;password=DBP@ss;database=IK" />
      </connectionStrings>
      <system.serviceModel>
        <services>
          <service name="NestleMiddlewareWCF.NestleMiddleware" behaviorConfiguration="ServiceBehaviour">
            <endpoint address="https://10.137.243.130:12345/NestleMiddleware.svc" binding="webHttpBinding" bindingConfiguration="webBinding" contract="NestleMiddlewareWCF.INestleMiddleware" behaviorConfiguration="web" />
          </service>
        </services>
          <bindings>
              <webHttpBinding>
                  <binding name="webBinding">
                      <security mode="Transport">       </security>
                  </binding>
              </webHttpBinding>
          </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="ServiceBehaviour">

              <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpsGetEnabled="true" httpsGetUrl="https://10.137.243.130:12345/NestleMiddleware.svc/mex" />
              <!-- 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>
          <endpointBehaviors>
            <behavior name="web">
              <webHttp />
            </behavior>
          </endpointBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
      </system.webServer>
      <applicationSettings>
        <NestleMiddlewareWCF.Properties.Settings>
          <setting name="NestleMiddlewareWCF_CopyService_Copy" serializeAs="String">
            <value>http://01hw361477:4880/_vti_bin/copy.asmx</value>
          </setting>
        </NestleMiddlewareWCF.Properties.Settings>
      </applicationSettings>
    </configuration>

1 Ответ

0 голосов
/ 14 марта 2012

Вам необходимо предоставить доступ к разделу файла конфигурации клиента, об этом сообщается об ошибке, и приведенный выше файл web.config выглядит как конфигурация хоста службы (или у него нет раздела клиента, что является проблемой).

...