It is very obvious! If you are reading this, you must be knowing how important it is to have an external interface for JIRA and how Atlassian helps by providing a SOAP interface. In an enterprise, or even in small companies for that matter, we often end up integrating JIRA with multiple systems. Creating a SOAP Client is a recommended and easy solution in such scenarios.
In fact, JIRA enables remote access through both SOAP and XML-RPC. SOAP is recommended because it covers more operations!
Before you can access JIRA through its SOAP API, you need to enable the JIRA rpc plugin. More on this and the creation of SOAP client can be found in the Atlassian pages. There are few examples as well to get you started.
So how does it all fit together? What are the simple steps to create a SOAP client. 1. Download the latest demo SOAP client distribution from the Atlassian public repository. This contains a Maven 2 project configured to use Apache Axis, and a sample Java SOAP client which creates test issues in http://jira.atlassian.com. You can alternatively download the source code at the end of the tutorial! 2. Modify the 'jira.soapclient.jiraurl' property in your pom.xml to point to your JIRA instance. By default it points to http://jira.atlassian.com 3. You can find the wsdl file under the /src/main/wsdl location. If it is not there or if you want to download the wsdl afresh, run the following command. mvn -Pfetch-wsdl -Djira.soapclient.jiraurl=http://{your_jira_instance}/
This will download the wsdl from the configured JIRA instance (as in Step 2) to /src/main/wsdl/. Skip the last property to download the Atlassian JIRA WSDL.
4. Now we have the wsdl ready and it is time to create the client jar. Run the following command to generate the sources from the wsdl and to create the SOAP client. mvn -Pbuildclient
This will generate a jar file with all the necessary classes required. There is a second jar file created with the dependencies (axis et. al.) embedded in it. The latter will do a world of good if you are executing it from an environment without axis etc already configured in it.
Let us now look at writing our SOAP program. We are trying the simplest approach , i.e to create the an Eclipse project by running the following. mvn eclipse:eclipse
You can alternatively try other IDEs or even run from command prompt , whatever is convinient. Let us just look at writing a simple program that just logs into our JIRA instance.
From now on, it is just another webservice invocation! The first step in writing the SOAP client is to get the SOAP service locator. Once you have the locator, get the SOAP service instance from the same by passing a new URL (of your JIRA instance). jiraSoapServiceLocator = new JiraSoapServiceServiceLocator(); jiraSoapService = jiraSoapServiceLocator.getJirasoapserviceV2(new URL(your_url));
Now you can login to JIRA simply by invoking the login operation as follows.
String token = getJiraSoapService().login(your_username, your_password);
The token here is very important as it is used for all the other operations instead of logging in every time. You can see the token as the first argument in all other operations.
Let us just try getting an issue using the key and print its key and id to prove that this stuff works! RemoteIssue issue = jiraSoapService.getIssue(authToken, ISSUE_KEY); System.out.println("Retrieved Issue:"+issue.getKey()+" with Id:"+issue.getId());
Hopefully that gives you a fair idea to get started with your first SOAP client! There are lot more you can do with the SOAP client some of which we will explain in our upcoming tutorials. Download some of the examples below. And don't forget to post your comments/feedback!
74 Comments
Divya Arun
3/29/2011 02:16:15 am
Hi,
Reply
J-Tricks
4/13/2011 07:46:52 am
Option 2 will never work as it is against the security policies and JIRA will never allow it.
Reply
Rym
4/28/2011 06:35:08 am
Hello,
Reply
J-Tricks
4/28/2011 06:47:45 am
Which folder are you running this command from? You should run it from the folder where the pom.xml resides (i.e. jira-soapclient folder).
Reply
Rym
4/28/2011 10:00:57 am
Hello again,
Reply
J-Tricks
4/28/2011 10:08:56 am
Well, atleast one hurdle is over!
Reply
Mukund
3/5/2012 11:28:35 pm
I am getting below exception
Reply
J-Tricks
3/6/2012 12:34:40 am
They are now moved to the Developers wiki. See https://developer.atlassian.com/display/DOCS/Atlassian+Maven+Repositories
Mukund
3/6/2012 03:56:46 pm
What are the changes required . Do i need to change the pom file with updated repository or something else ...
Rym
4/28/2011 08:15:59 pm
Hello again :)
Reply
J-Tricks
4/28/2011 08:37:52 pm
Cool.. Check out this page as well : http://confluence.atlassian.com/display/DEVNET/How+to+develop+without+the+Atlassian+Plugin+SDK
Reply
randi
5/2/2011 04:48:07 pm
Hi,
Reply
J-Tricks
5/2/2011 07:13:13 pm
Frankly I haven't ever tried it. Can't see any specific methods also. Will wait for someone to answer your query in the forums :)
Reply
med
5/4/2011 03:16:58 am
Hello,
Reply
J-Tricks
5/4/2011 08:23:59 am
You should get them as RemoteCustomFieldValue and print them as shown in the PrintAllCFs class in the attached source.
Reply
med
5/5/2011 03:02:23 am
Thnx J-Tricks, I try with this code, I make some modifications :
Reply
J-Tricks
5/5/2011 06:51:35 am
Bit confused.. I am not seeing the remoteCustomFieldValue variable either! Where have you declared it? RemoteCustomFieldValue is the class, not an instance, right?
Reply
med
5/8/2011 10:17:19 pm
Yes RemoteCustomFieldValue is the class, not an instance.
Reply
Venkat Prasad
5/8/2011 11:04:59 pm
Any help, appreciate on this error. Thank you. Note: it works on windows tomcat, but not linux version!
Reply
J-Tricks
5/9/2011 07:48:57 am
@med I am seeing only remoteCustomFieldValue which is not declared anywhere. That is the reason for compilation error. It is not the class because it starts with small 'r'.
Reply
J-Tricks
5/9/2011 07:51:32 am
@Venkat What is on linux machine? The client code? If so, did you look for any class path issues? Different versions of jar etc?
Reply
Michel
5/11/2011 10:49:08 pm
hello everybody,
Reply
J-Tricks
5/12/2011 09:45:44 am
I haven't seen a method for this in XML/RPC. There is one in SOAP though : progressWorkflowAction
Reply
5/19/2011 03:25:37 am
Hi,am trying to build but am getting error..Can you give me a idea what should specify at pom.xml and settings.xml,
Reply
J-Tricks
5/19/2011 08:12:22 am
Looks like you are running it behind a firewall. If so, add the proxy settings in your maven settings.xml. For details check http://maven.apache.org/guides/mini/guide-proxies.html .
Reply
5/20/2011 12:43:56 am
Thanks for your reply J-Tricks.
Reply
J-Tricks
5/20/2011 06:04:19 am
I am afrid I haven't got a clue here! Surely it must be an environment thing.
Reply
Mahalingam
5/31/2011 12:59:55 am
Using WSDL i have created the stubs using eclipse webservice client.
Reply
J-Tricks
5/31/2011 01:29:50 am
Hi Mahalingam,
Reply
Mahalingam
5/31/2011 06:36:57 pm
Hi J-Tricks,
Reply
J-Tricks
5/31/2011 07:19:16 pm
Do you mean the error is thrown at the last line?
Reply
Monica
6/5/2011 11:03:45 pm
Hello,
Reply
J-Tricks
6/6/2011 07:16:37 am
Monica,
Reply
Mahalingam
6/7/2011 02:22:50 am
Hi J-Tricks,
Reply
J-Tricks
6/7/2011 11:54:21 am
@Mahalingam sorry I didn't understand that fully. Are you saying that you got it working with 4.3.1? By saying it is working fine, returning the response?
Reply
Mahalingam
6/7/2011 06:11:27 pm
I have 2 environment setup now .One is with evulation version of 4.3.1 it is working fine.Another env is production evn..when i run the same client program am getting the error message.I already posted the error message for your response.It is related to embedded user classcast exception.So i thought ask you about the config if any?-Thanks for your time.
Reply
J-Tricks
6/7/2011 07:19:45 pm
Which version is you production JIRA instance? Are you using a client that is compatiable with it? Since it is working with your test env, the code must be fine. It should be a version collision I suspected earlier.
Reply
Mahalingam
6/8/2011 01:52:35 am
Production version is Jira4.3.1(same version i installed in my local machine)-the client code is working fine.I didnt get a clue why it is not working at production.I feel some configuartion related to embedded user is enabled.Still not able get any clue.Thanks for reponse.
Reply
J-Tricks
6/8/2011 09:16:56 pm
Doesn't ring any bell! Can you post back what the issue was if you figure it out later?
Reply
David
7/28/2011 05:42:00 am
Hello,
Reply
J-Tricks
8/1/2011 05:43:23 am
@David What are the methods that you find in the JiraSOAPServiceLocator ?
Reply
Charlie
8/3/2011 04:57:26 am
Now I have all the infrastructure in place.
Reply
J-Tricks
8/6/2011 02:57:22 am
Hi Charlie,
Reply
Anum
8/22/2011 05:15:38 pm
hello,
Reply
Anum
8/22/2011 05:17:36 pm
one more thing, what is i want to search the issue keys for a specific search term ,is it possible and will you elaborate how
Reply
J-Tricks
8/23/2011 10:26:38 am
@Anum You can use the getIssuesFromFilter or getIssuesFromTextSearch method to get those information. Check out http://svn.atlassian.com/svn/public/atlassian/rpc-jira-plugin/tags/atlassian_jira_3_13_5_1/src/java/com/atlassian/jira/rpc/soap/JiraSoapService.java for some explanation on those methods.
Reply
Anum
8/23/2011 05:29:16 pm
ok, i used the getIssuesFromTextSearch method to get the desired issues, but i have realized the retrieved issues are the one with the closed status, how can i get the issues of desired status,i.e. open, in progress and reopened
Reply
12/20/2011 07:30:00 am
Hi there,
Reply
J-Tricks
12/20/2011 09:34:10 am
@Joe I have no idea! Maybe find that property name from the old JIRA instance and set it to false in the new one as described under http://confluence.atlassian.com/display/JIRA/Advanced+JIRA+Configuration ?
Reply
Hi I'm successfully able to set this up and could run the client. I am able to execute login successfully and getting the token, but when I invoking getIssue from jirasoapservice, on JIRA 4.4.4, i am getting following exception. Requesting to pls help me with this. Another thing, I am able to run this service and get th response on 4.2.2, its only issue I;m facing in 4.4.4.
Reply
J-Tricks
3/12/2012 02:07:29 am
Seems you are getting a DB Exception. Looks like the problem comes from a plugin and not within your SOAP code.
Reply
Sabrina Chase
4/27/2012 07:04:33 am
I've downloaded the client project from the repository and even read the README file, but I am running into the problem of parent POM inheritance. It looks like there are at least three nested levels of POM files above the client. What are the necessary files and how do I get them without downloading the entire repository? Are there other dependencies that will need to be built before running the client? I don't need JIRA since I can point to our local version.
Reply
J-Tricks
4/27/2012 08:57:19 am
My guess is that you don't have settings.xml correctly configured! You don't need to add any dependencies by yourself.
Reply
Sabrina Chase
4/27/2012 09:04:58 am
That's entirely possible, but where do I find the correct values for the settings.xml? I looked on the atlassian site and found some for confluence (http://confluence.atlassian.com/display/CONF26/Atlassian+Maven+repositories) but I still get errors. I searched for Jira-specific dev settings but did not find them. Thanks...
kutty
6/14/2012 11:49:34 pm
i followed your tutorial and created the SOAP client, how to run it from eclipse?
Reply
J-Tricks
6/15/2012 02:02:43 am
The example already covers creating a client class in Eclipse. You can now call it just like any other Java projects in Eclipse. Just create a Main class with main method and then start invoking those methods!
Reply
Kavya
7/9/2012 10:59:16 am
Can you point me to the location where I can find the jar for the class "jiraSoapServiceLocator"?
Reply
J-Tricks
7/9/2012 03:01:52 pm
When you do "mvn -Pbuildclient" , the jar will be created! Follow the tutorial and you will see what I am talking about.
Reply
Srinivas
4/1/2013 01:05:51 pm
Thank you for this useful information. I configured SOAP client,performed some operations and found working fine. I got SocketTimedOutException when I tried to delete projects with more than 3000 issues though the projects are found deleted from UI. Will this approach creates any further issues?
Reply
J-Tricks
4/1/2013 01:31:47 pm
It won't create any issues. The actual operation takes more time and SOAP connection times out before it is completed.
Reply
Srinivas
4/1/2013 01:06:59 pm
I forgot to mention the error.
Reply
Hi,
Reply
J-Tricks
8/28/2013 02:58:18 am
I think you are using invalid component and version values?
Reply
luke
9/18/2013 09:12:18 pm
Hello there,
Reply
J-Tricks
9/23/2013 07:39:04 am
Make sure maven is installed and is available in the path. If you have Atlassian SDK installed, it comes with maven. You can use the absolute path to SDK_install_dir/bin
Reply
raj
9/19/2013 07:21:39 pm
i am gettin the following error:
Reply
J-Tricks
9/23/2013 07:36:41 am
Looks like an issue with maven settings. Were you able to run fetch-wsdl successfully?
Reply
raj
9/23/2013 10:03:49 pm
Thx for your reply, and no it wasn't successful, i was getting the following error:
J-Tricks
9/25/2013 03:11:16 pm
Seems the pom.xml is corrupted. Can you download the client in this example and see if that works?
raj
9/24/2013 06:52:00 am
Hey J-Tricks,
Reply
J-Tricks
9/25/2013 03:13:26 pm
1. I have used maven2 and specifically the one that comes with Atlassian Plugin SDK. Try that.
Reply
raj
9/25/2013 08:51:17 pm
Thanks for answering.
J-Tricks
9/26/2013 01:31:43 am
You have to change the wsdl to the one that is used by 4.3.2. Everything else will be same. Your comment will be posted after it is approved.
Leave a Reply. |
AuthorJobin Kuruvilla - Works in Adaptavist as Head of DevOps Professional Services. Categories
All
Archives
October 2016
|