Ich habe einen erholsamen .svc-less, dateilosen Dienst, der JSon-Daten zurückgibt. Es funktioniert gut, wenn es lokal ausgeführt wird, aber wenn ich in meinem lokalen IIS7 hosten, erhalte ich FehlerFileless Restful WCF funktioniert nicht, wenn es in lokalen IIS7 gehostet wird, aber lokal ausgeführt wird
Anforderungsfehler Der Server hat einen Fehler bei der Verarbeitung der Anfrage festgestellt. Weitere Informationen finden Sie in den Serverprotokollen.
Dies ist der Pfad der Web-Host-Anwendung in IIS.
localhost: 8080/AdventureWorksHost/EmployeeService/Mitarbeiter/GetEmployees
Aber funktioniert gut, wenn ich es in meinem Visual Studio laufen
localhost: 50182/employeeService/Mitarbeiter/GetEmployees
wo AdventureWorksHost ist ApplicationName gehostet unter Standardwebsite in IIS. Und EmployeeService ist der Name des Dienstes, die ich Dienst, den ich in global.asax.cs mit Standard-Endpunkten in webconfig Datei
hinzugefügt RouteTable.Routes.Add(new ServiceRoute("EmployeeService", new WebServiceHostFactory(), typeof(Services.EmployeeService.EmployeeService)));
ich mehrere Vorschlag in Stackoverflow und anderen Websites für ähnliches Problem aber keine Lösung überprüft habe, arbeitet für mich.
1) Ich habe die Standardportnummer 8080 für die Standardwebsite (unter der mein Projekt gehostet wird) in IIS7 zugewiesen und sichergestellt, dass diese Portnummer nicht von der Firewall oder einer Antivirenanwendung auf meinem Computer blockiert wird. 2) Ich prüfe WCF HTTP und Nicht-HTTP-Aktivierungen, WCF Services für alle .Net Framework verfügbar in Windows-Funktionen
3) ich gegeben habe, die Erlaubnis für IIS_IUSRS zum WebConfig meiner Anwendung hinzugefügt
4) lief ich dies in cmd prompt: aspnet_regiis.exe -iru C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319
5) ich ServiceModelReg.exe -i aus dem „% windir% lief \ Microsoft.NET \ Framework \ v3.0 \ Windows Communication Foundation "Verzeichnis zu re gister das Skript Karten
4) und 5) I verwendet forums.asp.net/t/1807824.aspx?WCF+Service+works+locally+but+returns+404+on+remote+server
6) Hinzugefügt unten nach stackoverflow.com/questions/4793127/404-when-running-net-4-wcf-service-on-iis-no-svc-file
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
ich habe jede Lösung versucht vorgeschlagen im Internet.Nichts funktioniert auf meinem lokalen IIS7
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
</configSections>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Users\Julian Luwang\Documents\Visual Studio 2013\Projects\AdventureWorksEntityFramework\AdventureWorksHost\Log\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<system.web>
<httpRuntime executionTimeout="1800000000" />
<compilation debug="true" targetFramework="4.5" />
<customErrors mode="On">
</customErrors>
</system.web>
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="test" helpEnabled="true" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None"></security>
</standardEndpoint>
</webHttpEndpoint>
</standardEndpoints>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<behaviors>
<serviceBehaviors>
<!--<behavior name="Secured">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>-->
<behavior>
<serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="false" />
</behavior>
<behavior name="Normal">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<!-- Binding (non-secured) -->
<binding name="Normal" transferMode="Streamed" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" closeTimeout="00:03:00" openTimeout="00:03:00" receiveTimeout="00:10:00" sendTimeout="00:03:00">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxDepth="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
<!--protocol mapping added-->
<protocolMapping>
<add scheme="http" binding="webHttpBinding" bindingConfiguration="Normal" />
</protocolMapping>
</system.serviceModel>
<connectionStrings>
<add name="AdventureWorks2012Entities" connectionString="metadata=res://*/AdventureWorksEDM.csdl|res://*/AdventureWorksEDM.ssdl|res://*/AdventureWorksEDM.msl;provider=System.Data.SqlClient;provider connection string="data source=JULIAN\SQLEXPRESS;initial catalog=AdventureWorks2012;integrated security=True;trusted_connection=yes;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<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>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" />
</handlers>
<directoryBrowse enabled="true" />
<defaultDocument enabled="false">
<files>
<add value="EmployeeService" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
Das Service
namespace AdventureWorksHost.Services.EmployeeService
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class EmployeeService : IEmployeeService
{
[WebGet(UriTemplate = "Employees/GetEmployees", ResponseFormat = WebMessageFormat.Json)]
public List<EmployeeItem> GetEmployee()
{
try
{
List<EmployeeItem> tReturn = new List<EmployeeItem>();
using (AdventureWorks2012Entities tClienEntities = new AdventureWorks2012Entities())
{
var tEmployees = (from es in tClienEntities.Employees
orderby es.JobTitle
select new
{
es.rowguid,
es.BirthDate,
es.BusinessEntityID,
es.JobTitle,
es.NationalIDNumber,
es.MaritalStatus,
es.LoginID,
}).ToList();
foreach (var tEmployee in tEmployees)
{
EmployeeItem tEmployeeItem = new EmployeeItem();
tEmployeeItem.rowguid = tEmployee.rowguid;
tEmployeeItem.BusinessEntityId = tEmployee.BusinessEntityID;
tEmployeeItem.JobTitle = tEmployee.JobTitle;
tEmployeeItem.MaritalStatus = tEmployee.MaritalStatus.ToString();
tEmployeeItem.NationalIDNumber = Int32.Parse(tEmployee.NationalIDNumber.ToString());
tEmployeeItem.BirthDate = tEmployee.BirthDate;
tEmployeeItem.LoginID = tEmployee.LoginID.ToString();
List<Person> Persons = new List<Person>();
foreach (var tPersons in (from esp in tClienEntities.People
where esp.BusinessEntityID == tEmployeeItem.BusinessEntityId
orderby esp.FirstName
select new
{
esp.rowguid,
esp.FirstName,
esp.MiddleName,
esp.LastName,
esp.PersonType,
esp.Demographics
}))
{
Persons.Add(new Person()
{
rowguid = tPersons.rowguid,
FirstName = tPersons.FirstName,
MiddleName = tPersons.MiddleName,
LastName = tPersons.LastName,
PersonType = tPersons.PersonType,
Demographics = tPersons.Demographics
});
}
tEmployeeItem.Persons = Persons;
tReturn.Add(tEmployeeItem);
}
}
return tReturn;
}
catch (FaultException ex)
{
throw (ex);
}
}
}
}
Meine Anwendung AdventureWorkHost wie folgt aussehen in meinem lokalen IIS7
Ist es wegen der Datenbank im lokalen SQL Server? Ich habe irgendwo gelesen, dass, wenn mein root-Konto meines IIS7 als das gleiche Administrator-Konto ich für meinen SQL-Server (ohne ein Passwort) verwendet, dann sollte es keine Datenbank-Problem sein. –