WCF Rest Service Template 40 on IIS 7.5

I am attempting to get the WCF Rest Service Template 40 (CS) which is an online template in VS 2010 to deploy to IIS 7.5 on Win Server 2008 R2. We havn't changed the template at all and are trying to get this call to work:

public class Service1
{
    // TODO: Implement the collection resource that will contain the SampleItem instances

    [WebGet(UriTemplate = "")]
    public List GetCollection()
    {
        // TODO: Replace the current implementation to return a collection of SampleItem instances
        return new List() { new SampleItem() { Id = 1, StringValue = "Hello" } };
    } ....

We've tried:

  • manually creating an .svc file as this template doesn't have one. looks like:
  • publishing as a website and adding it as a website in IIS.
  • we've installed .net framework 4.0 on IIS and that is working.
  • adding some webconfig stuff to attempt to get the endpoints from the Global.asax.
  • a bunch of other stuff...

I am pulling my hair out over this and sorry I can't be more specific about what exactly is going on. The problem we are getting is the service calls such as http://localhost/Service1 can't be found thru IIS but they work fine in VS.

Here is the webservice file:

how do you insert xml? http://www.nitricburnstudios.com/Web.config

1
задан Luke Belbina 23 August 2010 в 03:25
поделиться

2 ответа

После долгих разочарований, наконец, понял, как заставить это работать.

Необходимо включить перенаправление HTTP в IIS.

Это можно сделать, выбрав

  1. Панель управления -> Программы и компоненты
  2. Включите или отключите функции Windos
  3. В разделе «Роли» добавьте веб-сервер -> общие функции http -> роль перенаправления http

Это вроде как указано здесь: http://blogs.msdn.com/b/rjacobs/archive/2010/06/30/system-web-routing-routetable-not-working-with-iis.aspx

2
ответ дан 2 September 2019 в 21:55
поделиться

По умолчанию, когда вы переключаетесь на публикацию в IIS, это делается в vdir, а не в корне веб-сайта, поэтому я предполагаю, что вам нужно проверить vdir, в который он устанавливается (свойства проекта , web) и измените URL-адрес, к которому вы пытаетесь получить доступ, на http: // localhost / WcfRestService1 / Service1 (или что-то еще).

Когда я создаю проект из шаблона, переключаюсь на публикацию IIS, нажимаю F5, а затем нажимаю этот URL-адрес, я получаю ожидаемый результат очень хорошо:

<ArrayOfSampleItem xmlns="http://schemas.datacontract.org/2004/07/WcfRestService1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <SampleItem>
    <Id>1</Id> 
    <StringValue>Hello</StringValue> 
  </SampleItem>
</ArrayOfSampleItem>
0
ответ дан 2 September 2019 в 21:55
поделиться
Другие вопросы по тегам:

Похожие вопросы: