Выдача метаданных wcf rest - PullRequest
       4

Выдача метаданных wcf rest

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

Итак, я пытаюсь создать службу отдыха, но получаю сообщение об ошибке:

enter image description here

Если я пытаюсь запустить его в браузере, я получаю: The type 'WcfService2.Service1', provided as the Service attribute value in the ServiceHost directive could not be found.

namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public class HelloWorldService
    {
        [OperationContract]
        [WebGet(UriTemplate = "")]
        public string HelloWorld()
        {
            return "Hello world!";
        }
    }
}

namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.

    class Program
    {
        static void Main(string[] args)
        {
            WebHttpBinding binding = new WebHttpBinding();
            WebServiceHost host =
            new WebServiceHost(typeof(HelloWorldService));
            host.AddServiceEndpoint(typeof(HelloWorldService),
            binding,
            "http://localhost:8000/Hello");
            host.Open();
            Console.WriteLine("Hello world service");
            Console.WriteLine("Press <RETURN> to end service");
            Console.ReadLine();
        }
    }
}

1 Ответ

1 голос
/ 16 марта 2012

Вы определяете REST-стиль WCF, используя WebHttpBinding.

Тестовый клиент WCF можно использовать только для SOAP сервисов, но не для сервисов REST. Службы REST можно протестировать с помощью обычного браузера или таких инструментов, как Fiddler.

Сообщение об ошибке, которое вы получаете, почти указывает на то, что у вас где-то тоже есть *.svc, что мешает вам. Это тот случай?

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