Delen via


De Windows Process Activation Service configureren voor gebruik met Windows Communication Foundation

In dit onderwerp worden de stappen beschreven die nodig zijn voor het instellen van windows procesactiveringsservice (ook wel BEKEND als WAS) in Windows Vista voor het hosten van WCF-services (Windows Communication Foundation) die niet communiceren via HTTP-netwerkprotocollen. In de volgende secties worden de stappen voor deze configuratie beschreven:

  • Installeer (of bevestig de installatie van) de WCF-activeringsonderdelen die vereist zijn.

  • Maak een WAS-site met de netwerkprotocolbindingen die u wilt gebruiken of voeg een nieuwe protocolbinding toe aan een bestaande site.

  • Maak een toepassing om uw services te hosten en ervoor te zorgen dat die toepassing de vereiste netwerkprotocollen kan gebruiken.

  • Bouw een WCF-service die een niet-HTTP-eindpunt beschikbaar maakt.

Een site configureren met niet-HTTP-bindingen

Als u een niet-HTTP-binding met WAS wilt gebruiken, moet de sitebinding worden toegevoegd aan de WAS-configuratie. Het configuratiearchief voor WAS is het bestand applicationHost.config, dat zich bevindt in de map %windir%\system32\inetsrv\config. Dit configuratiearchief wordt gedeeld door ZOWEL WAS als IIS 7.0.

applicationHost.config is een XML-tekstbestand dat kan worden geopend met elke standaardteksteditor (zoals Kladblok). Het iis 7.0-opdrachtregelprogramma (appcmd.exe) is echter de voorkeursoptie om niet-HTTP-sitebindingen toe te voegen.

Met de volgende opdracht wordt een net.tcp-sitebinding toegevoegd aan de standaardwebsite met behulp van appcmd.exe (deze opdracht wordt ingevoerd als één regel).

appcmd.exe set site "Default Web Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']  

Met deze opdracht wordt de nieuwe net.tcp-binding toegevoegd aan de standaardwebsite door de onderstaande regel toe te voegen aan het bestand applicationHost.config.

<sites>  
    <site name="Default Web Site" id="1">  
        <bindings>  
            <binding protocol="HTTP" bindingInformation="*:80:" />  
            //The following line is added by the command.  
            <binding protocol="net.tcp" bindingInformation="808:*" />  
        </bindings>  
    </site>  
</sites>  

Een toepassing inschakelen voor het gebruik van niet-HTTP-protocollen

U kunt afzonderlijke netwerkprotocollen op toepassingsniveau in- of uitschakelen. De volgende opdracht laat zien hoe u zowel de HTTP- als net.tcp-protocollen inschakelt voor een toepassing die wordt uitgevoerd in de Default Web Site.

appcmd.exe set app "Default Web Site/appOne" /enabledProtocols:net.tcp  

De lijst met ingeschakelde protocollen kan ook worden ingesteld in het <element applicationDefaults> van de XML-configuratie van de site die is opgeslagen in ApplicationHost.config.

De volgende XML-code van applicationHost.config illustreert een site die is gebonden aan zowel HTTP- als niet-HTTP-protocollen. De aanvullende configuratie die nodig is om niet-HTTP-protocollen te ondersteunen, wordt aangeroepen met opmerkingen.

<sites>  
    <site name="Default Web Site" id="1">  
      <application path="/">  
        <virtualDirectory path="/" physicalPath="D:\inetpub\wwwroot" />  
      </application>  
      <bindings>  
            <!-- The following two lines are added by the command. -->
            <binding protocol="HTTP" bindingInformation="*:80:" />  
            <binding protocol="net.tcp" bindingInformation="808:*" />  
       </bindings>  
    </site>  
    <siteDefaults>  
        <logFile
        customLogPluginClsid="{FF160663-DE82-11CF-BC0A-00AA006111E0}"  
          directory="D:\inetpub\logs\LogFiles" />  
        <traceFailedRequestsLogging
          directory="D:\inetpub\logs\FailedReqLogFiles" />  
    </siteDefaults>  
    <applicationDefaults
      applicationPool="DefaultAppPool"
      <!-- The following line is inserted by the command. -->
      enabledProtocols="http, net.tcp" />  
    <virtualDirectoryDefaults allowSubDirConfig="true" />  
</sites>  

Als u probeert een service te activeren met WAS voor niet-HTTP-activering en u WAS niet hebt geïnstalleerd en geconfigureerd, ziet u mogelijk de volgende fout:

[InvalidOperationException: The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.]   System.ServiceModel.AsyncResult.End(IAsyncResult result) +15778592   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +15698937   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +265   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +227   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171  

Als u deze fout ziet, controleert u of WAS voor niet-HTTP-activering is geïnstalleerd en juist is geconfigureerd. Zie Procedures: WCF-activeringsonderdelen installeren en configureren voor meer informatie.

Een WCF-service bouwen die GEBRUIKMAAKT van WAS voor niet-HTTP-activering

Zodra u de stappen voor het installeren en configureren van WAS hebt uitgevoerd (zie Procedure: WCF-activeringsonderdelen installeren en configureren), is het configureren van een service voor gebruik van WAS voor activering vergelijkbaar met het configureren van een service die wordt gehost in IIS.

Zie How to: Host a WCF Service in WAS voor gedetailleerde instructies over het bouwen van een WCF-service die is geactiveerd.

Zie ook