Ich versuche, einen WCF-Dienst einzurichten, aber ich habe ein paar Probleme. Die Arbeiten Service und lädt die Wsdl Seite, wenn ich inWCF Service 404 Fehler
www.mydomain.com/Service1.svc
geben Sie jedoch, wenn ich
www.mydomain.com/Service1.svc/
verwenden oder versuchen, eine der get-Methoden zu verwenden, die ich
The resource cannot be found.
Description: HTTP 404.
My Web erhalten .config-Datei lautet wie folgt
<?xml version="1.0"?>
<configuration>
<system.webServer>
<handlers>
<remove name="PageHandlerFactory-ISAPI-4.0"/>
<add name="PageHandlerFactory-ISAPI-4.0" path="*" verb="GET,HEAD,POST,DEBUG" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<remove name="ASP.NET-ISAPI-4.0-Wildcard"/>
<add name="ASP.NET-ISAPI-4.0-Wildcard"
path="*" verb="GET,HEAD,POST,DEBUG"
modules="IsapiModule"
scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll"
preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<remove name="svc-Integrated-4.0" />
<add name="svc-Integrated-4.0" path="*" verb="*" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
<system.web>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.0">
</compilation>
<httpHandlers>
<remove verb="*" path="*.svc"/>
<add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
</httpHandlers>
</system.web>
<system.serviceModel>
<services>
<service name="RestService.Service1" behaviorConfiguration="ServiceBehaviour" >
<endpoint address="" binding="webHttpBinding" contract="RestService.IService1" behaviorConfiguration="web">
</endpoint>
<host>
<baseAddresses>
<add baseAddress="http://mydomain.com/Service1"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour" >
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Die Service.svc Datei ist wie folgt:
namespace RestService
{
public class Service1 : IService1
{
public bool LoginUser(string Username, string password)
{
return true;
}
}
}
und die IService.cs ist wie folgt:
namespace RestService
{
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
//BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "login/{username}/{password}")]
bool LoginUser(string username, string password);
}
}
Die Pipeline-Modus auf dem Server ist "Integrated", ob das hilft. Ich bin nicht sicher, welche IIS-Version mein Hosting-Provider (pipeten) verwendet, aber ich denke, es ist 7.5 Ich habe das Gefühl, dies hat etwas mit der URL-Validierung zu tun, aber es gibt keine Option auf meinem Hosting, dies zu ändern.
zeigen einige Ihrer Service-Methoden und die Anforderungs-URL Sie erstellen. – Chandermani
Hosten Sie auf IIS? Geben Sie auch Ihre IIS-Version und Ihre Umgebung an. – Rajesh
Ich habe weitere Informationen hinzugefügt, um die Methoden anzuzeigen, die ich erstellt habe! – kiwijus