Проблема клиента службы WCF - PullRequest
2 голосов
/ 13 июня 2011

Я пытаюсь создать клиента для службы WCF, которую я разместил на IIS 5.1. У меня странная проблема: я могу получить доступ к службе через браузер просто отлично, я вижу «Вы создали service ", но всякий раз, когда я пытаюсь запустить svcutil (как предложено на той же странице)

svcutil.exe http://my.host.name/SampleService/SampleService.svc?wsdl

Я получаю следующую ошибку:

Error: Cannot obtain Metadata from http://localhost.ms.com/SampleService/SampleS
ervice.svc?wsdl

If this is a Windows (R) Communication Foundation service to which you have acce
ss, please check that you have enabled metadata publishing at the specified addr
ess.  For help enabling metadata publishing, please refer to the MSDN documentat
ion at http://go.microsoft.com/fwlink/?LinkId=65455.


WS-Metadata Exchange Error
URI: http://localhost.ms.com/SampleService/SampleService.svc?wsdl

Metadata contains a reference that cannot be resolved: 'http://localhost.ms.
com/SampleService/SampleService.svc?wsdl'.

The HTTP request is unauthorized with client authentication scheme 'Anonymou
s'. The authentication header received from the server was 'Negotiate'.

The remote server returned an error: (401) Unauthorized.


HTTP GET Error
URI: http://localhost.ms.com/SampleService/SampleService.svc?wsdl

There was an error downloading 'http://localhost.ms.com/SampleService/Sample
Service.svc?wsdl'.

The request failed with an empty response.

If you would like more help, type "svcutil /?"

Что может быть причиной этой проблемы?

РЕДАКТИРОВАТЬ: это может быть проблема с самим IIS? Например, неправильно установлены разрешения?

РЕДАКТИРОВАТЬ: Вот мой web.config:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="Basic">
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
    </bindings>

    <services>
      <service name="DummyService2.SampleService"
           behaviorConfiguration="DummyService2.SampleServiceBehavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="basicHttpBinding" contract="DummyService2.ISampleService"
              bindingConfiguration="Basic" />
        <endpoint address="mex" binding="basicHttpBinding" contract="IMetadataExchange"
              bindingConfiguration="Basic" />
      </service>
    </services>


    <behaviors>
      <serviceBehaviors>
        <behavior name="DummyService2.SampleServiceBehavior">
          <!-- 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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

1 Ответ

1 голос
/ 13 июня 2011

Я думаю, что это соответствующая ошибка:

HTTP-запрос не авторизован с помощью схемы аутентификации клиента «Аноним».Заголовок аутентификации, полученный от сервера, был «Согласовать».

Защищен ли пароль веб-службы или используется встроенная проверка подлинности Windows?Если я правильно помню, svcutil не может войти со встроенной аутентификацией в веб-сервис.Когда вы используете браузер, он работает просто отлично, потому что он обрабатывает аутентификацию в фоновом режиме для сред интрасети.

Один из вариантов - загрузить и сохранить wsdl вручную, а затем указать svcutil использовать загруженный файл wsdl для генерацииклассы.Возможно, вам придется скачать некоторые файлы, на которые ссылается wsdl, и отредактировать ссылки.

...