zoukankan      html  css  js  c++  java
  • JS 调用WCF config

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <connectionStrings>
        <add name="conn" connectionString="server=.;database=Users;uid=sa;pwd=123456;" />
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
     
      <system.serviceModel>
        <behaviors>
          <endpointBehaviors>
            <behavior name="webBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="">
              <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
              <serviceMetadata httpGetEnabled="true"/>
              <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息 -->
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"
          multipleSiteBindingsEnabled="true" >
          <baseAddressPrefixFilters>
            <add prefix="string"/>
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
          <service name="IUserTest" >
            <endpoint address="" behaviorConfiguration="webBehavior"
              binding="webHttpBinding" contract="IUserTest" />
            <!--<endpoint address="" binding="basicHttpBinding" contract="ReaderService"  />-->
          </service>
        </services>
        <bindings>
            <webHttpBinding>
              <binding name="webBinding" crossDomainScriptAccessEnabled="true"></binding>
            </webHttpBinding>
        </bindings>
      </system.serviceModel>
     
     <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
     
    </configuration>

    注:1.在svc的文件中<%@ ServiceHost Language="C#" Debug="true" Service="WCFTest.UserTest" CodeBehind="UserTest.svc.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

    要加上Factory="System.ServiceModel.Activation.WebServiceHostFactory"

    2.在代码上加上 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

    3.在接口上加上 [WebInvoke(ResponseFormat = WebMessageFormat.Json,UriTemplate="/方法名", Method="GET" ,BodyStyle = WebMessageBodyStyle.Wrapped)]

  • 相关阅读:
    3.默认参数的注意事项
    2.关键字global,nonlocal
    1.函数的结构,调用,传参,形参,实参,args,kwargs,名称空间,高阶函数
    19. 实现一个整数加法计算器(多个数相加):
    20.文件操作
    18.使用for循环计算+1-3+5-7+9-11+13...99的结果
    ubuntu docker更新镜像源
    虚拟环境的使用
    前端基础之HTML
    jQuery基本使用
  • 原文地址:https://www.cnblogs.com/ZJ199012/p/2395746.html
Copyright © 2011-2022 走看看