Apache Axis2 Java client to access Bronto SOAP WSDL

Posted on 2012-08-22
Last Modified: 2012-08-28
I've downloaded Apache Axis2, using the following link:

Then I used the following command to generate java classes: -uri
total generated src:

I was able to login with help using the following.
BrontoSoapApiImplServiceStub stub;

// Get the stub...

LoginE loginE = new LoginE();
Login login = new Login();

login.setApiToken("your token here");

// Call the web service; login

Open in new window

Now I try to addContacts, and needs SessionHeaderE, but I can't seem to link login to the sessionId, the following code is not right. I'm imaging after login, I should be able to get some session info. But I can't seem to find.
SessionHeader sessionHeader = new SessionHeader();
sessionHeader.setSessionId(param)  // I don't know how to get sessionId from login info
SessionHeaderE sessionHeaderE = new SessionHeaderE();

Open in new window

By the way, this is my first time working with Axis. Not sure what's the best way to approach the problem.
Question by:xiaoyunwu
    LVL 35

    Accepted Solution

    You are correct in that what the login call returns is the session information, you just have to dig a little to find the id. But you should just be able to follow the types that Axis has created, from LoginResponseE -> LoginResponse -> _return. Change the login call to this...

    String sessionId = stub.login(loginE).getLoginResponse().get_return();

    Open in new window

    Then you can use the sessionId for subsequent calls.

    Author Closing Comment

    Hi mccarl,

    This is so helpful. I used your method and it worked perfectly. I was able to addContacts to Bronto now.

    One question: is so long and there're more than 200,000 lines in it. How did you know loginResponse.get_return() return the sessionId? Is it because it returned String?

    When you say: "follow the types that Axis has created", is that mean get_return() returns String and sessionId is a String, and we think login should have sessionId information, so you guessed get_return() will return sessionId? I wanted to know how I can get all these myself in the future.

    Thanks a lot for your help!!!
    LVL 35

    Expert Comment

    Ok, 2 main points to this...

    1) In response to your questions above... Well, firstly, I started with the API documentation which I found here,, and if you look at the 'Overview' section and in that the 'How to login' section, the text states the the login function returns the sessionId. So now I know where to start. (BTW, I think the code samples it gives is for a different version of Axis, see below). Then the use of a good IDE helps a lot. I use Eclipse, and basically, I just found the login() method by using the find function. This shows that it returns an object of type 'LoginResponseE' (and know the good part) and you can just control-click on LoginResponseE and Eclipse takes you straight to the definition of that type. In that type you see that it is just a holder for a 'LoginResponse' type which you receive via the getLoginResponse() method, so again, control-click that type to take you to it's definition, and it is just a holder for a String which you receive via get_return() method call. And since lines up with the text of the documentation, I assumed it was your sessionId.

    2) As I mentioned above, the code samples look a lot cleaner than you have needed to do. I looked into this further and it turns out that Apache Axis (as opposed to Axis2) handles all this a much different way. If you are able to use the older Axis, you might find that it can make your life easier, and give you the ability to follow the code samples more closely. I found an axis-1_4 here,, and to run WSDL2Java you have to invoke it differently, like this...
    C:\Program Files (x86)\Java\axis-1_4>java -cp lib\axis.jar;lib\commons-discovery-0.2.jar;lib\commons-logging-1.0.4.jar;lib\jaxrpc.jar;lib\saaj.jar;lib\wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java

    Open in new window


    Author Comment

    mccarl, Thank you so much for detailed information. I really learned a lot!

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This video teaches viewers about errors in exception handling.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now