zoukankan      html  css  js  c++  java
  • WCF HelpPage 和自动根据头返回JSON XML

    WCF

    通过Web.config设置,

    1 automaticFormatSelectionEnabled项便可实现返回内容自动根据Content-Type和Accept 返回JSON或者XML

    2helpEnabled="true"实现 HelpPage,在接口加Description特性

    <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <standardEndpoints>
          <webHttpEndpoint>
            <!--
                Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
                via the attributes on the <standardEndpoint> element below
            -->
            <standardEndpoint name="" helpEnabled="true" defaultOutgoingResponseFormat="Json" automaticFormatSelectionEnabled="true"/>
          </webHttpEndpoint>
        </standardEndpoints>
      </system.serviceModel>

     [ServiceContract]
        public interface IUserService : IBaseWCFService
        {
            [WebGet(UriTemplate = "userID={userID}")]
            [Description("根据UserID获取用户信息")]
            UserInfo GetUserInfo(string userID);
        }

    注册服务节点 RouteTable.Routes.Add(new ServiceRoute("Services/UserService", new WebServiceHostFactory(), typeof(UserService)));

    http://localhost:30760/Services/UserService/help

    此页面介绍此终结点上的服务操作。

    Uri方法描述
    userID={userID} GET 根据UserID获取用户信息
  • 相关阅读:
    JS事件
    BOM
    DOM
    常见的SQL字符串函数
    常用的认证方式
    后台代码扫描规则-sonarQube官方
    spring cloud中feign的使用
    常见基于 REST API 认证方式
    Java中连接池
    这是一张心情贴
  • 原文地址:https://www.cnblogs.com/rosanshao/p/2450692.html
Copyright © 2011-2022 走看看