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

  • 相关阅读:
    .Net Core 第三方工具包整理
    .Net Core 读取appsettings.json的配置
    .Net Core 常见问题整理
    .Net Core 学习资料
    LVM使用
    PIP本地源搭建
    sed命令使用
    Shell脚本
    SNAT端口转发配置
    Ubuntu软件包管理
  • 原文地址:https://www.cnblogs.com/denglinhai/p/3378461.html
Copyright © 2011-2022 走看看