MS Visual Studio: почему не удается добавить ссылку на Web- сервис? Add Service Reference Error.

Коллеги, приветствую.

В конфигурации реализован простой веб- сервис, прототип для дальнейших решений, скажем так..

Контракт:

 

namespace SimpleCustomService
{
    [ServiceContract]
    public interface UsrIService
    {
        [OperationContract]
        string SayHello(string value);
    }
}

 

Реализация:

 

namespace SimpleCustomService
{
    public class UsrService : UsrIService
    {
        public string SayHello(string value)
        {
            return "Hello" + value;
        }
    }
}

 

В браузере я могу обратиться к WSDL:

 

http://localhost:8080/0/ServiceModel/SimpleCustomService.svc?wsdl

 

Или так:

 

http://localhost:8080/0/ServiceModel/SimpleCustomService.svc?singleWsdl

 

Но когда я пытаюсь добавить ссылку в проект MS Visual Studio, получаю ошибку:

По ссылке Details следующее:

 

The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://localhost:8080/0/ServiceModel/SimpleCustomService.svc?wsdl'.
The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '



xmlns="http://www.w3.org/1999/xhtml">
> http-equiv="X-UA-Compatible" content="IE=Edge" /> http-equiv="Content-Type" content="text/html; charset=utf-8" />> href="favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" /><span style="color: #000000; font-weight: bold;">>
    bpm'online bank customer journey
>

   

Нравится

2 комментария

Собственно, есть альтернативный ход - сохранить wsdl локально и использовать утилиту wsdl.exe.. Все же хотелось бы понять, почему не удается добавить ссылку - был бы весьма признателен, если бы кто- нибудь поделился знаниями.

Если кликнуть по "Advanced" и затем вписать в URL ссылку на wsdl, то в поле "Web services found at this URL" всегда "The HTML document does not contain Web service discovery information.", а Web reference name и Add reference всегда disabled.

Добрый день, Алексей!

В svc файле должна быть объявлена Factory. Пример ниже.

<%@ ServiceHost Language="C#" Debug="true" Factory="System.ServiceModel.Activation.WebServiceHostFactory" Service="Terrasoft.WebApp.Loader.ServiceModel.AuthService" %>

Показать все комментарии