简体   繁体   English

无法远程或本地访问IIS 7中托管的WCF Rest方法

[英]Not able to access WCF Rest method hosted in IIS 7 remotely or locally

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. 直接从Visual Studio运行服务,我可以使用http://localhost:12827/HighONDealsService/GetDeals/43.1656/-77.6114调用REST WebGet方法,但是在远程服务器上的IIS中部署我的服务后,我无法访问WebGet方法了。

My service can be seen here http://155.98.38.135:12827/HighONDealsService.svc 在这里可以看到我的服务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 我可以访问该服务,甚至可以访问该服务的帮助页面,但不能访问实际的服务方法http://155.98.38.135:12827/HighONDealsService/help

My actual service directory has Read & Execute permissions for Network Service and IIS_IUSRS. 我的实际服务目录具有网络服务和IIS_IUSRS的读取和执行权限。

My Global.asax.cs file looks like 我的Global.asax.cs文件看起来像

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 : 我尝试了上述线程中的步骤,但无济于事这是我的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> 从Visual Studio实例运行的服务的Fiddler跟踪显示了完整的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> <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"/> 但是IIS中托管的服务的Fiddler跟踪显示空白<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. 问题似乎出在Windows身份验证/集成安全性与实体框架到后端的连接上。 Working on it :) 正在努力:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM