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

推荐订阅源

D
DataBreaches.Net
Y
Y Combinator Blog
I
InfoQ
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
IT之家
IT之家
H
Help Net Security
月光博客
月光博客
S
SegmentFault 最新的问题
B
Blog
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
G
Google Developers Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
Vercel News
Vercel News
博客园 - 叶小钗
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss

博客园 - 阿拉伯顶峰

网页兼容调试笔记 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();                
            }