Authorization for a Multi-Cloud System

This is a project design I am currently working on to consume SPIFFE(Secure Production Identity Framework For Everyone) bootstrapped trust and identification to provide authorization in a dynamically scaling, heterogeneous system, inspired by Mr. Prabath Siriwardena from WSO2 and under the supervision of Prof. Gihan Dias from University of Moratuwa. An enterprise system running across multiple clouds, as in the hybrid cloud, is an obvious example that will be benefitted from this. The objective is to open doors for the SPIFFE standard based systems to co-exist with rest of the systems with minimal effort, without compromising on security aspects while having an authorization solution based on SPIFFE.
What is SPIFFE? In brief, it is a trust bootstrapping and identification framework, submitted as a standard and accepted by CNCF(Cloud Native Computing Foundation)[1]. As of now, this standard has two main implementations as SPIRE and Istio[2], a platform that supports service mesh archit…

How to convert WSDL to Java


Basically WSDL (Web Services Development Language) is an XML document used to describe or locate web services. WSDL stands for Web Services Description Language. The document describes a Web service. It specifies the location of the service and the operations that can be taken. 

WSDL2Java is distributed with Axis2 package of Apache and need to set-up Axis2 to use this service. A guide to set-up Axis2 can be found in apache organization documents .WSDL 2.0 is the currently using version. Obviously JDK should be properly installed too. Note: For the 3rd method you are not needed to set these things by yourself.

The WSDL document includes server Java programs for Web services and generated classes using WSDL2Java feature includes client stubs, server skeletons and data types that can help in writing client side. The generated stub classes play a great role in distributed computing and if you are interested can read on what are stub classes. In brief talking, if there is an interested web service, that you want to consume, and if you have the WSDL file of service you can generate the stub and code the client to use stub. This will need lot more plug-ins and dependencies to work properly and will have to configure as needed.


The following are few methods to convert WSDL to java 

  (1)  Using Maven

First create a Maven module in whatever IDE you use (As I know Netbeans and IntelliJ IDEA support this). It will create a project structure as follows. As you can see a default pom.xml file will be created. This is to include relevant details needed to build project in Maven and if you are new to pom.xml files intoduce yourself the pom.xml.
There inside the 'main' directory create another directory named 'resources' parallel to java directory. Java directory is to hold the source code relevant to client that you are going to generate. For the moment it can be empty. 

Place the relevant WSDL files of the services you are interested, inside resources as shown above and now lets go for the pom.xml file.

There in the task section, include all the WSDL files that you want to convert to Java as in the above figure and edit the "arg line" so as to identify the relevant WSDL file of each web service. You will have to edit few other sections like plug-ins and resources and those should be done as needed by the web services you are trying to consume.

Once you have finished above steps open a terminal and go to the directory where pom.xml file is located. Then enter the command "mvn clean " and then "mvn install". Of course you can enter "mvn clean install" at once. But separating it is the recommended way as procedure is clear by then.

 If you have set-up Axis2 properly and edited pom.xml correctly this command will generate a directory called 'target' and it will include the relevant stub classes and few other classes needed by the project. Now you can carry on developing the client to consume services in the stub classes.

   ( 2)Using Apache Ant

 Apache-ant is another tool that can be used to generate stub classes. I have not tried out it yet and here is a guidance to build Stubs using ant.

  (3) In Command-line

Converting WSDL to Java can be done using terminal commands too. First create your folder structure and go inside the directory you are going to code the client. Then to generate stub class enter the following command,
"wsdl2java -s -uw -uri URL or path to WSDL file"
Here -s implies web service invocation is synchronous. Simply once the client make a request, it waits without doing anything else until the reply comes.

          -uw implies unwrapping option switch on. This creates the methods in stub classes are capable of one-step unwrapping of the XML data in a message.

         -uri implies URL or path of the WSDL file

This command will create folder structure according to the WSDL file and will create an ant build.xml file. Inside the src directory in some inner directory you will find the generated stub classes. Now the client code can be placed there or somewhere else importing the relevant stub classes.

   (4) Using WSO2 ESB

Here you do not need to have installed Axis2. Instead except for installation of JDK, you need to install WSO2 ESB. This is not a big task and downloading, running the system, accessing service via browser are the steps to follow. You can have detailed instructions at WSO2 Enterprise Service Bus (ESB) Installation Guide . There in the user interface you will find the tool WSDL2Java among few other tools like Java2WSDL in the left-hand side.

 When you go for WSDL2Java tool it will allow you to enter the relevant path of WSDL file and few other options. You can select them as want and click on "Generate" button.

 This will automatically download the generated code with stub classes to your local machine and you can place it any where as needed and carry on developing the client.

I am preferring the first method as we can see what really is happening and directly the procedure is inside the project. There can be smarter methods than these four.


  1. @Pushpalanka can you write a sample java code for calling a stub??

  2. Are there some advantages of one language C and Java over the other? Which one is optimal? Which one is more "future proof"? Would it be optimal to know both? If so, which order? I am a little confused on the subject. Just got across this course, will it be helpful also. A little enlightenment could help. Thanks

  3. Thanks for a great article. Your tips are accurate and they will be of great help to me with my business, although it's not a nonprofit one. I bookmarked your site, will be back ! !

  4. This comment has been removed by a blog administrator.

  5. This comment has been removed by a blog administrator.

  6. Hi Pushpalanka,

    I am trying to write a java program which convert wsdl to client without using Axis2 or any other inbuilt or 3rd party tools.

    Can you please post some important fact or guideline to do this.
    or any references..

    Or can you share the source code, as in above post you have done using maven.
    Thanks in Advance


Post a Comment

Popular posts from this blog

Signing SOAP Messages - Generation of Enveloped XML Signatures

How to send an HTML email in Java (Using Google SMTP Server)