簡體   English   中英

無法遠程或本地訪問IIS 7中托管的WCF Rest方法

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

我的問題看上去與此線程中討論的問題相似。 檢查了該線程並完成了所有步驟,但是我的問題存在

直接從Visual Studio運行服務,我可以使用http://localhost:12827/HighONDealsService/GetDeals/43.1656/-77.6114調用REST WebGet方法,但是在遠程服務器上的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;
}

從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>

但是IIS中托管的服務的Fiddler跟蹤顯示空白<ArrayOfDealObject xmlns="http://schemas.datacontract.org/2004/07/HighONDealsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"/>

我在這里做錯了什么?

問題似乎出在Windows身份驗證/集成安全性與實體框架到后端的連接上。 正在努力:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM