惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
A
About on SuperTechFans
Y
Y Combinator Blog
V
V2EX
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Visual Studio Blog
博客园 - 叶小钗
博客园 - 聂微东
阮一峰的网络日志
阮一峰的网络日志
H
Help Net Security
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
B
Blog
G
Google Developers Blog
J
Java Code Geeks
博客园 - 三生石上(FineUI控件)
IT之家
IT之家
N
Netflix TechBlog - Medium
腾讯CDC

博客园 - 阿拉伯顶峰

网页兼容调试笔记 NSoup解析处理Html jeasyui控件事件和方法的使用方法 JavaScriptSerializer 序列号datatime时少了8小时 正则表达式一 jeasyui-datagrid使用笔记 javascript笔记 excel拼接函数 2014年最简单、快捷的美股Scottrade开户攻略 将ppt转换成PDF chrome开发配置(四)生成项目及配置库引用 chrome开发配置(三)安装开发工具 chrome开发配置(二)获取源代码 chrome开发配置(一)安装配置工具 ie6 js报错unterminated string constant 关于请求添加HttpRequestHeader SqlServer数据库正在还原的解决办法 dwz ie10一直提示数据加载中 Windows Server 2008下IIS 7配置ASP+ACCESS环境
wso2 data services返回json数据方法
阿拉伯顶峰 · 2013-10-19 · via 博客园 - 阿拉伯顶峰

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

修改\repository\conf\axis2目录下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();                
            }