zoukankan      html  css  js  c++  java
  • WCF在 IIS上面 部署的步骤

    1. 安装完 VS Extension 后,我们可以创建一个 WCF service 的网站项目。
    2. 添加一个 WCF service 新项,系统自动会创建 Service.svc、App_Code\Service.cs 等必要文件。
    3. 在 Service.cs 文件中完成服务编码。
    4. 添加 web.config 文件,并在其位置单击鼠标右键,打开 "Microsoft Service Configuration Editor" 工具完成服务配置。
    5. 注意添加 serviceMetadata,否则我们使用浏览器无法查看,也无法创建客户端代理。

    web.config 演示 (注意配置文件中并没有提供服务地址)
    <?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      
    <system.serviceModel>
        
    <services>
          
    <service behaviorConfiguration="MyServiceTypeBehaviors" name="MyService">
            
    <endpoint binding="wsHttpBinding" contract="IMyService"/>
          
    </service>
        
    </services>
        
    <behaviors>
          
    <serviceBehaviors>
            
    <behavior name="MyServiceTypeBehaviors">
              
    <serviceMetadata httpGetEnabled="true"/>
              
    <serviceDebug includeExceptionDetailInFaults="true"/>
            
    </behavior>
          
    </serviceBehaviors>
        
    </behaviors>
      
    </system.serviceModel>
      
    <system.web>
        
    <compilation debug="true">
      
    </system.web>
    </configuration>
    service.svc
    <%@ ServiceHost Language="C#" Debug="true" Service="MyService" CodeBehind="~/App_Code/service.cs" %>
    建议将服务放到一个单独的 Library 中,这样更改宿主环境会更方便一点,不过上述步骤要做些修改。
    1. 安装完 VS Extension 后,我们可以创建一个 WCF service 的网站项目。
    2. 添加服务所在类库的引用。
    3. 创建 svc 文件,内容也所不同。如 <%@ ServiceHost Debug="true" Service="Learn.Library.WCF.CalculateService" %>,注意使用包含名字空间的全名。
    4. 添加 web.config 文件,打开 "Microsoft Service Configuration Editor" 工具完成服务配置。
    5. 注意添加 serviceMetadata,否则我们使用浏览器无法查看,也无法创建客户端代理。
    web.config
    <?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
      
    <system.serviceModel>
        
    <services>
          
    <service behaviorConfiguration="MyServiceTypeBehaviors" name="Learn.Library.WCF.CalculateService">
            
    <endpoint binding="wsHttpBinding" contract="Learn.Library.WCF.ICalculate"/>
          
    </service>
        
    </services>
        
    <behaviors>
          
    <serviceBehaviors>
            
    <behavior name="MyServiceTypeBehaviors">
              
    <serviceMetadata httpGetEnabled="true"/>
              
    <serviceDebug includeExceptionDetailInFaults="true"/>
            
    </behavior>
          
    </serviceBehaviors>
        
    </behaviors>
      
    </system.serviceModel>
      
    <system.web>
        
    <compilation debug="true">
      
    </system.web>
    </configuration>
  • 相关阅读:
    数据库自动备份
    VC查找文件特定位置的记录方法
    MFC利用ADO连接ACCESS数据库及其操作数据库的方法
    VC利用ODBC连接MySql数据库的方法及其操作数据的方法
    uwsgi和nginx的故事
    A JavaScript Image Gallery
    The DOM in JavaScript
    A brief look at the Objects in JavaScript
    3 ways of including JavaScript in HTML
    #3 working with data stored in files && securing your application (PART II)
  • 原文地址:https://www.cnblogs.com/pdfw/p/1014293.html
Copyright © 2011-2022 走看看