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:
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
После долгих разочарований, наконец, понял, как заставить это работать.
Необходимо включить перенаправление HTTP в IIS.
Это можно сделать, выбрав
Это вроде как указано здесь: http://blogs.msdn.com/b/rjacobs/archive/2010/06/30/system-web-routing-routetable-not-working-with-iis.aspx
По умолчанию, когда вы переключаетесь на публикацию в 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>