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

  • 相关阅读:
    基于Kibana的可视化监控报警插件sentinl入门
    es聚合学习笔记
    spark streaming基本概念一
    es实战一:基本概念
    访问者模式(Visitor Pattern)
    模板方法模式(Template Method Pattern)
    策略模式(Strategy Pattern)
    状态模式(State Pattern)
    观察者(Observer)模式
    备忘录模式(Memento Pattern)
  • 原文地址:https://www.cnblogs.com/ZJ199012/p/2395746.html
Copyright © 2011-2022 走看看