Building a JSON web service with Java and Axis2
来源:互联网 发布:js鼠标跟随特效 编辑:程序博客网 时间:2024/05/17 08:18
Building a JSON web service with Java and Axis2
January 23rd, 2009 · 9 Comments
It is said that in Java usually the easiest things are the hardest. The following is a nice example as it took me some time to figure out how to do it.
I wanted to build a simple URL request based web service in Java that returns an JSON object. Yes, you can do that with a simple Servlet too, the advantage of usingAxis2 is that you can also call your deployed services using SOAP without any configuration changes.
- Download Axis2 as WAR and install it in your servlet container
- Download the DynamicResponseHandler module and add it to Axis by copying it to WEB-INF/modules
- Patch Jettison or download my patched version and replace it with the one installed in WEB-INF/lib
- Add the DynamicResponseHandler module reference to the axis2.xml configuration (located in WEB-INF/conf):
<module ref="DynamicResponseHandler"/>
- Add the JSON Message formatters to the axis2.xml:
<messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/><messageFormatter contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
- Add JSON Message builders to the axis2.xml:
<messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/><messageBuilder contentType="application/json/badgerfish" class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
- Start your servlet container and test the standard version service by calling this url:
http://localhost:8080/axis2/services/Version/getVersion?response=application/json
Now you are ready to add your own web services. Here you can find an example how to deploy a simple POJO service. Have fun!
Update: Zeno (see comments) sent me patch for usage with Jettison 1.2 – otherwise he received a NullPointerException. I haven’t checked it, but I hope it helps you! Thanks Zeno!
- Building a JSON web service with Java and Axis2
- Building a JSON web service with Java and Axis2
- Web Service Security with Axis2
- Web Service Security with Axis2
- Python Programming with the Java(TM) Class Libraries: A Tutorial for Building Web and Enterprise App
- Building a RESTful Web Service
- Building a RESTful Web Service
- Building a RESTful Web Service
- Compiling and building a project with rebar
- SpringBoot 之 Building a RESTful Web Service
- Spring Building a RESTful Web Service
- Spring Boot: Building a RESTful Web Service
- Apache Axis2(java web service)备忘记
- Building and Running a Web Application
- Building Web Services with Java: Making Sense of XML, SOAP, WSDL and UDDI
- Java EE 7: Building Web Applications with WebSocket, JavaScript and HTML5
- Spring REST Client with RestTemplate: Consume RESTful Web Service Example for XML and JSON
- Spring REST Client with RestTemplate: Consume RESTful Web Service Example for XML and JSON
- 含Ajax项目的 Response.Write 使用
- myeclipse9安装SVN插件(myeclipes9 M1)
- ibatis介绍
- mark一下,正式搬家到CSDN
- 深入Java虚拟机JVM类加载初始化学习笔记
- Building a JSON web service with Java and Axis2
- 99%成年人算错的小学题
- 苹果宣布CEO乔布斯辞职 COO库克接任
- jQuery 的异步方法与JSON
- android 下怎样获取图片像素值
- X264码率控制流程分析
- 【解决方案】Windows7 下面玩不了魔兽争霸3
- 学以致用!回忆一下从3个月前到现在,学习python的历程
- POJ 3740 Easy Finding 详细讲解