zoukankan      html  css  js  c++  java
  • 基于iis下 wcf接口发布

    添加新建项目

    在默认程序中

    配置 web.config文件 配置   system.serviceModel   

    <services>
    			<service name="s.Service1">
    				<endpoint binding="webHttpBinding" behaviorConfiguration="WebBehavior" contract="s.IService1" />
    			</service>
    		</services>
    		<behaviors>
    			<!--WCF中提供了Web HTTP的方式-->
    			<endpointBehaviors>
    				<behavior name="WebBehavior">
    					<webHttp helpEnabled="true" />
    				</behavior>
    			</endpointBehaviors>
    
    			<serviceBehaviors>
    				<behavior name="WebBehavior">
    					<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
    					<serviceDebug includeExceptionDetailInFaults="false" />
    				</behavior>
    			</serviceBehaviors>
    			<!--<serviceBehaviors>
            <behavior>
              -->
    			<!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false -->
    			<!--
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
              -->
    			<!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
    			<!--
              <serviceDebug includeExceptionDetailInFaults="false"/>
    			
            </behavior>
          </serviceBehaviors>-->
    
    		</behaviors>
    		<protocolMapping>
    			<add binding="basicHttpsBinding" scheme="https" />
    		</protocolMapping>
    		<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    

      

    配置接口允许跨域

    <httpProtocol>
    <customHeaders>
    <add name="Access-Control-Allow-Origin" value="*" />
    <add name="Access-Control-Allow-Headers" value="*" />
    <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE" />
    </customHeaders>
    </httpProtocol>

    最后接口定义中 iservice默认post

    添加配置文件

    [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]

  • 相关阅读:
    java中过滤器和拦截器的区别
    Java中内部类和静态内部类的区别
    SpringBoot启动的时候切换配置文件命令
    centos7安装Subversion
    关于curl_setopt参数的记录
    Linux Samba文件共享服务,安装与案例配置
    CentOS7源码安装Redis5.0.4非关系型数据库
    Centos7部署LAMP平台之架构之路
    Centos7安装及配置DHCP服务
    CentOS 7源码安装MYSQL-5.6
  • 原文地址:https://www.cnblogs.com/v587yy/p/12698654.html
Copyright © 2011-2022 走看看