Не удается получить доступ к методу WCF Rest, размещенному в IIS 7, удаленно или локально

Моя проблема выглядит аналогично той, которая обсуждалась в этой теме. Проверена эта тема и пройдены все этапы, но моя проблема существует.

Запустив сервис напрямую из Visual Studio, я могу вызвать метод REST WebGet, используя http://localhost:12827/HighONDealsService/GetDeals/43.1656/-77.6114, но после развертывания моей службы в IIS на удаленном сервере я больше не могу получить доступ к методу WebGet.

Мой сервис можно увидеть здесь http://155.98.38.135:12827/HighONDealsService.svc

Я могу связаться со службой, и даже со страницей справки для службы, но не с указанием способа обслуживания. http://155.98.38.135:12827/HighONDealsService/help

Мой действительный каталог службы имеет разрешения на чтение и выполнение для службы сети и IIS_IUSRS.

Мой файл Global.asax.cs выглядит так

protected void Application_Start(object sender, EventArgs e)
    {
        RouteTable.Routes.Add(new ServiceRoute("HighONDealsService", new WebServiceHostFactory(), typeof(HighONDealsService)));
    }

Я попробовал шаги в вышеупомянутой теме, но безрезультатно. Это мой web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <sectionGroup name="system.serviceModel"    type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="standardEndpoints" type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
        </sectionGroup>
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </configSections>

    <system.web>
        <compilation debug="true" targetFramework="4.5">
            <assemblies>
                <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            </assemblies>
        </compilation>
        <pages controlRenderingCompatibilityVersion="4.0" />
        <identity impersonate="false" />
        <authentication mode="Windows" />
    </system.web>

    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">      
        </serviceHostingEnvironment>
        <standardEndpoints>
            <webHttpEndpoint>
                <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"></standardEndpoint>
            </webHttpEndpoint>
        </standardEndpoints>
    </system.serviceModel>

    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true" />
        <directoryBrowse enabled="true" />
    </system.webServer>

    <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
            <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
    </entityFramework>

    <connectionStrings><add name="DataContext" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=PC535\SQLEXPRESS;initial catalog=CSharpTeamProject;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
</configuration>

Фактическая реализация сервиса:

/// <summary>
/// 
/// </summary>
[ServiceContract]
public interface IHighONDealsService
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="userLat"></param>
    /// <param name="userLong"></param>
    /// <returns></returns>
    [OperationContract]
    [WebGet(UriTemplate = "GetDeals/{userLat}/{userLong}")]
    List<DealObject> GetDeals(string userLat, string userLong);        
}

/// <summary>
/// 
/// </summary>
[DataContract]
public class DealObject
{
    [DataMember]
    public string City;

    [DataMember]
    public string Category;

    [DataMember]
    public string SearchResult;

    [DataMember]
    public decimal Latitude;

    [DataMember]
    public decimal Longitude;

    [DataMember]
    public string Deals;

    [DataMember]
    public string Address;
}

Трассировка Fiddler для службы, запущенной из экземпляра Visual Studio, показывает полный XML-ответ <ArrayOfDealObject xmlns="http://schemas.datacontract.org/2004/07/HighONDealsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><DealObject><Address i:nil="true"/><Category>Bars</Category><City>Rochester</City><Deals>Stay late and get drunk - free drinks on the house after 10pm</Deals><Latitude>43.160850</Latitude><Longitude>-77.601294</Longitude><SearchResult>Tavern 58 At Gibbs</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Hospital</Category><City>Rochester</City><Deals>Get your pet checked up for free all winter long</Deals><Latitude>43.176582</Latitude><Longitude>-77.551338</Longitude><SearchResult>Laurelton Animal Hospital</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Airport</Category><City>Rochester</City><Deals>Enjoy your stay with complimentary spa sessions</Deals><Latitude>43.130763</Latitude><Longitude>-77.668665</Longitude><SearchResult>Fairfield Inn Rochester Airport</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Pizza</Category><City>Rochester</City><Deals>Get 1 large Pizza with every Sheet Pizza</Deals><Latitude>43.138420</Latitude><Longitude>-77.594986</Longitude><SearchResult>Salvatore's Pizzeria</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Restaurants</Category><City>Rochester</City><Deals>Dollar 5 discount on every takeaway</Deals><Latitude>43.153626</Latitude><Longitude>-77.608005</Longitude><SearchResult>Dinosaur Barbeque</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Bars</Category><City>Rochester</City><Deals>Happy hours all this month</Deals><Latitude>43.119709</Latitude><Longitude>-77.619911</Longitude><SearchResult>Sheridan's Pub</SearchResult></DealObject><DealObject><Address i:nil="true"/><Category>Gas Station</Category><City>Rochester</City><Deals>Get 3 car washes for dollar 10 only</Deals><Latitude>43.138942</Latitude><Longitude>-77.669807</Longitude><SearchResult>Anthony's Sunoco</SearchResult></DealObject></ArrayOfDealObject>

Но трассировка Fiddler для службы, размещенной в IIS, отображается пустой <ArrayOfDealObject xmlns="http://schemas.datacontract.org/2004/07/HighONDealsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>

Что я здесь не так делаю?

1 ответ

Решение

Проблема, по-видимому, связана с подключением Windows Authentication/Integrated Security for Entity Framework к бэкэнду. Работаю над этим:)

Другие вопросы по тегам