zoukankan      html  css  js  c++  java
  • wso2 data services返回json数据方法

    一、首先要修改下配置文件。

    修改 epositoryconfaxis2目录下axis2.xml与axis2_client.xml配置文件。

    增加<parameter name="httpContentNegotiation">true</parameter>配置

    axis2.xml代码段如下:

        <!-- ================================================= -->
        <!-- Parameters -->
        <!-- ================================================= -->
        <parameter name="hotdeployment">true</parameter>
        <parameter name="hotupdate">true</parameter>
        <parameter name="enableMTOM" locked="false">optional</parameter>
        <parameter name="cacheAttachments">true</parameter>
        <parameter name="attachmentDIR">work/mtom</parameter>
        <parameter name="sizeThreshold">4000</parameter>
        <parameter name="httpContentNegotiation">true</parameter>
        <parameter name="EnableChildFirstClassLoading">${childfirstCL}</parameter>

    axis2_client.xml代码段如下:

        <!--If turned on with use the Accept header of the request to determine the contentType of the
        response-->
        <parameter name="httpContentNegotiation">true</parameter>


    二、访问服务

                WebClient w = new WebClient();
                w.Headers.Add(HttpRequestHeader.Accept, "application/json");           
                using (StreamReader sr = new StreamReader(w.OpenRead("http://192.168.1.123:9763/services/ccjy.HTTPEndpoint/getrestnews?num=4")))
                {                
                    string a =sr.ReadToEnd();                
                }

  • 相关阅读:
    Redis 设计与实现-内部数据结构
    RuntimeBinderException 异常
    IPv4和IPv6地址库
    -Xms -Xmx -Xmn -Xss -XX:
    倒计时
    列表操作-分片赋值
    20175316毕设准备Day1-2
    20175316毕业设计——基于区块链服务的仓库管理系统
    Python学习笔记:sys.argv入参
    Python学习笔记:bisect模块实现二分搜索
  • 原文地址:https://www.cnblogs.com/denglinhai/p/3378461.html
Copyright © 2011-2022 走看看