代码之家  ›  专栏  ›  技术社区  ›  Krishna Kumar

IIS5.1(XP)中承载WCF服务的步骤

  •  1
  • Krishna Kumar  · 技术社区  · 17 年前

    2 回复  |  直到 17 年前
        1
  •  5
  •   marc_s MisterSmith    17 年前

    1) 您需要一个IIS虚拟目录-->使用IIS管理器创建它

    2) 您需要一个引用您的服务的*.svc文件-它是一个文本文件,必须位于您刚刚创建的虚拟目录中,类似于:

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

    不

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

    3) 您需要web.config中的配置-您至少需要 <service> 根据您的需要,可能会添加更多标签:

    <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>
    

    在这里,您需要决定使用什么绑定(协议)。

    http://yourserver/virtualdirectory/YourService.svc )并查看您服务的“登录页”。

    马克

        2
  •  1
  •   Nader Shirazie    17 年前

    this article on MSDN . 它包含有关在所有版本的IIS中托管WCF服务的信息。

    推荐文章