本文介绍了如何在IIS 6.0上部署WCF服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 WCF 和服务部署完全陌生.我在IIS 6.0上设置服务时遇到问题.

I am completely new to WCF and deploying of services. I am having trouble setting up my service on IIS 6.0.

我需要确切的步骤在IIS 6.0上部署我的 WCF 服务.

I need the exact steps to deploy my WCF service on IIS 6.0.

注意:我创建了一个 WCF 服务应用程序...

Note: I created a WCF service application...

那么,在IIS 6.0上部署wcf服务需要遵循的确切步骤是什么?

So, what is the exact steps i need to follow to deploy my wcf service on IIS 6.0?

推荐答案

我相信您基本上有两种选择:

You have basically two options, I believe:

选项1-"bin"部署(首选选项)

  1. 将WCF服务编译为DLL(类库)
  2. 在IIS6中创建网站
  3. 将WCF DLL复制到网站的.\ bin 文件夹
  4. 在该网站中创建一个 *.svc 文件
  5. 在网站文件夹中添加适当的 web.config 来定义您的端点和服务配置等.
  1. compile your WCF service into a DLL (class library)
  2. create a website in IIS6
  3. copy the WCF DLL's into the website's .\bin folder
  4. create a *.svc file in that website
  5. add an appropriate web.config in the website folder to define your endpoints and service configuration etc.

您现在可以在网站的基本地址以及 *.svc 文件的名称(例如

Your WCF service will now be reachable at the website's base address, plus the name of the *.svc file, e.g.

http://myserver/someweb/Myservice.svc

您的 *.svc 看起来像这样:

<%@ ServiceHost Language="C#" Debug="true"
    Service="WCF_Simple_Service.HelloIndigoService"  %>

Service = 属性表示实现服务的类-完全符合其名称空间.

The Service= attributes denotes the class implementing the service - fully qualified with its namespace.

选项2-将内容放入 App_Code

Option 2 - put stuff into App_Code

  1. 在IIS6中创建网站
  2. 将所有与WCF相关的 *.cs 文件直接放入.\ App_Code 文件夹
  3. 在该网站中创建一个 *.svc 文件
  4. 在网站文件夹中添加适当的 web.config 来定义您的端点和服务配置等.
  1. create a website in IIS6
  2. put all your WCF related *.cs files directly into the .\App_Code folder
  3. create a *.svc file in that website
  4. add an appropriate web.config in the website folder to define your endpoints and service configuration etc.

您现在可以在网站的基本地址以及 *.svc 文件的名称(例如

Your WCF service will now be reachable at the website's base address, plus the name of the *.svc file, e.g.

http://myserver/someweb/Myservice.svc

您的 *.svc 看起来像这样:

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

一个简单的示例 web.config 可能看起来像这样:

A simple, sample web.config might look something like this:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="WithDebug">
                <serviceMetadata httpGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  <services>
    <service name="SimpleWCF.HelloIndigoService" behaviorConfiguration="true">
      <endpoint
          address=""
          binding="basicHttpBinding"
          contract="SimpleWCF.IHelloIndigoService" />
      <endpoint
          address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange" />
    </service>
  </services>
</system.serviceModel>

您基本上定义了< service> 标记-再次: name = 表示实现服务的类-完全符合其名称空间.它必须至少包含一个端点-由于IIS6仅支持HTTP,因此可以使用 basicHttpBinding wsHttpBinding ,这就是全部."mex"端点是可选的-但非常有用,特别是对于开发和测试.它允许客户端发现"服务并获取其服务描述,以便可以与之交互.

You basically define your <service> tag - and again: the name= denotes the class implementing the service - fully qualified with its namespace. It must contain at least one endpoint - since IIS6 only support HTTP, you can use basicHttpBinding or wsHttpBinding and that's about all there is. A "mex" endpoint is optional - but very useful, especially for development and testing. It allows client to "discover" the service and get its service description so it can interface with it.

一旦您的服务部署在IIS中,您就可以使用 WCF测试客户端,或通用的 SoapUI SOAP测试实用程序(具有免费版本供您使用).

Once your service is deployed in IIS, you can see it in action using a tool like the WCF Test Client that ships for free with WCF, or SoapUI which is a general-purpose SOAP testing utility (with a free edition for you to use).

这篇关于如何在IIS 6.0上部署WCF服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 18:30