开发者

Steps to host a WCF service in IIS5.1(XP)

I have developed a sample WCF service. I would like to know the steps t开发者_StackOverflow社区o host this in IIS 5.1(XP)


1) You need a IIS virtual directory --> create it using IIS Manager

2) You need a *.svc file which references your service - it's a text file which must reside inside your virtual directory just created, and it would be something like:

<% @ServiceHost Service="YourNameSpace.YourServiceClass" 
                Language="C#" Debug="False" %>

That works if your WCF service class is in an assembly deployed to the "bin" directory below your virtual directory.

If you happen to have your actual service code in a "code-behind" file inside your "App_Code" directory (which I would not recommend), then you'd need this contents in your *.svc file:

<% @ServiceHost Service="YourServiceClass" 
                CodeBehind="~/App_Code/YourServiceClass.cs"
                Language="C#" Debug="False" %>

3) You need your config in web.config - you need at least the <service> tag plus possibly more depending on your needs:

<system.serviceModel>
   <services>
      <service name="YourNameSpace.YourServiceClass"
               behaviorConfiguration="MetadaTaEnabled">
         <endpoint address="" 
                   binding="wsHttpBinding" 
                   contract="YourNameSpace.IYourService" />
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MetadaTaEnabled">
          <serviceMetadata httpGetEnabled="True"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

Here, you need to decide what binding (protocol) to use.

If you do all this, and everything was successful, you should be able to browse to your virtual directory URL with IE (http://yourserver/virtualdirectory/YourService.svc) and see the "landing page" of your service.

Marc


Have a look at this article on MSDN. It has information about hosting WCF services in all versions of IIS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜