2010-12-10 6 views
0

Création d'un nouveau répertoire XYZ dans IIS 7.0. Copié web.config, Service.cs et Service.svc dans le répertoire. Maintenant sur la navigation http://www.mydomain.com/XYZ/Service.svc je reçois une «500 erreur de serveur interne».Déploiement d'un service WCF simple sur un serveur Web

Voici le fichier web.cofig.

<?xml version="1.0"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true"/>   
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 

Je pense qu'il pourrait y avoir un problème avec le fichier de configuration, mais le service fonctionne assez bien sur la machine locale.

Répondre

1

Dans un premier temps, vous devez utiliser dll-file au lieu du fichier de code. Compilez le code et placez dll dans le dossier "bin".

Au deuxième, vous n'avez pas ajouté points de terminaison dans web.cofnig:

<system.serviceModel> 
<!-- ... --> 
    <services> 
     <service name="SiteService"> 
      <endpoint address="" binding="basicHttpBinding" 
       contract="Name of the service interface with namespace, for exanple WebApplication1.IService1" /> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services>  
</system.serviceModel> 

et contrôleront fichier svc, à l'intérieur d'un nom de service doit correspondre à un nom de service dans un fichier de configuration. Si un service a une ligne <service name="SiteService">, le fichier svc doit être

<%@ ServiceHost Language="C#" Debug="true" Service="SiteService" CodeBehind="Service.cs" %>