zoukankan      html  css  js  c++  java
  • 配置AJAX Enabled WCF在hosting时: Showing the serviceMetadata in an ASP.NET AJAX Service

    Here's an example of configuring a web.config file to show the meta data for an ASP.NET 3.5 AJAX WCF service.

    In this case, you first add the service using Add New Item -> AJAX-Enabled WCF Service -> (Name WeatherService.svc) -> Add.

    Next, configure the web.config's <system.serviceModel> section to look like this:

    <system.serviceModel>
    <services>
    <service name="WeatherService"
    behaviorConfiguration="WeatherServiceAspNetAjaxBehavior">

    <endpoint address=""
    binding="webHttpBinding" contract="WeatherService" />
    <endpoint contract="IMetadataExchange"
    binding="mexHttpBinding" address="mex" />
    </service>
    </services>
    <behaviors>
    <endpointBehaviors>
    <behavior name="WeatherServiceAspNetAjaxBehavior">
    <enableWebScript />
    </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
    <behavior name="WeatherServiceAspNetAjaxBehavior" >
    <serviceMetadata httpGetEnabled="true" />
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    </system.serviceModel>

     使得:

    endpointBehaviors  &serviceBehaviors 共用一个名字。

     或者如下:

    <behaviors>
          <endpointBehaviors>
            <behavior name="AjaxBehavior">
              <enableWebScript />
            </behavior>
          </endpointBehaviors>
          <serviceBehaviors>
            <behavior name="AjaxServiceBehavior">
              <serviceMetadata httpGetEnabled="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
     
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
        
        <services>
          <service behaviorConfiguration="AjaxServiceBehavior" name="ShoppingCartService">
            <endpoint address="" behaviorConfiguration="AjaxBehavior"
                      binding="webHttpBinding" bindingConfiguration="AjaxBinding"
                      contract="ShoppingCartService" />
            <endpoint address="" behaviorConfiguration="AjaxBehavior" binding="webHttpBinding" bindingConfiguration="AjaxSecureBinding" contract="ShoppingCartService" />
          </service>  
        </services>

  • 相关阅读:
    2016.10.15先占坑
    2016.10.11先占坑
    2016.10.13先占坑
    2016.10.7先占坑
    main()里面为什么要放String[] args
    对于一个给定的正整数 n ,请你找出一共有多少种方式使 n 表示为若干个连续正整数的和,要求至少包括两个正整数。
    求两个数的最大公约数的三种算法总结
    C++
    Dev-c5.11的使用
    客户端和服务器端的交互(未完待续)
  • 原文地址:https://www.cnblogs.com/simonhaninmelbourne/p/1517626.html
Copyright © 2011-2022 走看看