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

  • 相关阅读:
    #Leetcode# 700. Search in a Binary Search Tree
    很多很多书上代码
    #Leetcode# 104. Maximum Depth of Binary Tree
    #Leetcode# 12. Integer to Roman
    PAT-2018年冬季考试-乙级
    PAT 1035 插入与归并
    PAT 1058 选择题
    PAT 1052 卖个萌
    CodeForces Round #521 (Div.3) E. Thematic Contests
    2017Nowcoder Girl初赛重现赛
  • 原文地址:https://www.cnblogs.com/denglinhai/p/3378461.html
Copyright © 2011-2022 走看看