Showing posts with label Axis. Show all posts
Showing posts with label Axis. Show all posts

Tuesday, July 29, 2014

Java - JAXB marshalling and unmarshalling of ArrayList

Marshalling and unmarshalling of ArrayList using JAXB is rather simple however you cannot directly marshall ArrayList. You will need a holder class (wrapper class). It will hold the arraylist that you want to marshall or unmarshall.

Please see the self explanatory java code below -

Output -

--Marshalling--
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<List>
    <Value>one</Value>
    <Value>two</Value>
    <Value>three</Value>
</List>

--Unmarshalling--

[one, two, three]

Tuesday, July 24, 2012

How to use Apache Axis2 for consuming a web service?

About the example:


In this example we will see how to use rather consume a web service using Apache Axis2. We have a Hello World web service which is already published, it accepts a String name and prints Hello name in return. To know more about how to publish a web service, click here.

Below are the steps which shows how to consume a web service using Apache Axis2

1. Download latest version of axis2 files from http://axis.apache.org/axis2/java/core/. (i.e. axis2-1.6.2-bin.zip).


2. Extract the folder (i.e. axis2-1.6.2) in your desire location. Lets assume as C:\axis2-1.6.2.

3. Add enviroment variable AXIS2_HOME and set the value "C:\axis2-1.6.2". Also make sure that JAVA_HOME is set in enviroment variables.

4. Now you can use wsdl2java.bat file from folder "C:\axis2-1.6.2\bin" to download web service stubs. Use command prompt and go to folder C:\axis2-1.6.2\bin and run below command.

   wsdl2java.bat -uri http://localhost:8080/SimpleWebservice/hellows?wsdl

   Note : Provide your wsdl URL in above command, you can also use XSD file instead of wsdl URL. Here we have already published a hello world web services. To know how to publish a simple hello world web service, click here.

   Please see the screen shot below.