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();                
                }

  • 相关阅读:
    第九周学习进度
    用户场景描述
    第九天
    第10天
    求两个有序数组的中值
    计算字符串中最长子字符串的长度
    计算两个数之和
    将string 转int
    判断一个int 型整数 是否为回文数
    php 对象的一些特性
  • 原文地址:https://www.cnblogs.com/denglinhai/p/3378461.html
Copyright © 2011-2022 走看看