문제

My problem looks similar to the one discussed in this thread Checked this thread and went through all the steps but my problem exists

Running the service directly from visual studio, I am able to invoke the REST WebGet method using http://localhost:12827/HighONDealsService/GetDeals/43.1656/-77.6114, but after deploying my service in IIS on a remote server i'm unable to access the WebGet method anymore.

My service can be seen here http://155.98.38.135:12827/HighONDealsService.svc

I'm able to reach the service, and even the help page for the service but not the actual service method http://155.98.38.135:12827/HighONDealsService/help

My actual service directory has Read & Execute permissions for Network Service and IIS_IUSRS.

My Global.asax.cs file looks like

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

I tried the steps in the above mentioned thread, but to no avail This is my 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>

Actual Service Implementation :

/// <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;
}

The Fiddler Trace for the service running from a visual studio instance shows the full xml response <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>

But the Fiddler Trace for the service hosted in IIS shows blank <ArrayOfDealObject xmlns="http://schemas.datacontract.org/2004/07/HighONDealsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>

What am I doing wrong here?

도움이 되었습니까?

해결책

The problem seems to be with Windows Authentication/Integrated Security for Entity Framework connectivity to the backend. Working on it :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top