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

  • 相关阅读:
    [CSP-S模拟测试]:attack(支配树+LCA+bitset)
    [杂题]:C/c(二分答案)
    [杂题]:B/b(二分答案)
    二维莫队(离线)
    [CSP-S模拟测试]:联盟(搜索+树的直径)
    [CSP-S模拟测试]:蔬菜(二维莫队)
    [CSP-S模拟测试]:施工(DP+单调栈+前缀和)
    [CSP-S模拟测试]:画作(BFS+数学)
    [CSP-S模拟测试]:折射(DP)
    [CSP-S模拟测试]:养花(分块)
  • 原文地址:https://www.cnblogs.com/v587yy/p/12698654.html
Copyright © 2011-2022 走看看