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获取用户信息
  • 相关阅读:
    werfault进程使用CPU率高
    oracel 拆分字符串
    TCP TIME WAIT
    netstat 命令
    Java 理论与实践: 并发集合类
    DIV与SPAN之间有什么区别
    oracle超出打开游标的最大数的原因和解决方案
    Quartz表达式
    Axis创建webservice客户端和服务端
    Web服务cxf框架发布2
  • 原文地址:https://www.cnblogs.com/rosanshao/p/2450692.html
Copyright © 2011-2022 走看看