SOAP-dust example: querying jira codehaus

First: put this in a file named QueryJiraWithSoapdust.java

import java.io.IOException;

import soapdust.Client;
import soapdust.ComposedValue;
import soapdust.FaultResponseException;
import soapdust.MalformedResponseException;
import soapdust.MalformedWsdlException;

public class QueryJiraWithSoapdust {

    public static void main(String[] args) 
    throws IOException, MalformedWsdlException, FaultResponseException, MalformedResponseException {
       Client client = new Client();
       client.setWsdlUrl("http://jira.codehaus.org/rpc/soap/jirasoapservice-v2?wsdl");
       client.setEndPoint("http://jira.codehaus.org/rpc/soap/jirasoapservice-v2");
       
       String authKey = null;
       try {
       	   ComposedValue authentication = new ComposedValue();
       	   //see http://jira.codehaus.org to create an account if you dare.
       	   authentication.put("in0", "your login"); //put your login here
       	   authentication.put("in1", "your password"); //put your password here
       
       	   ComposedValue login = client.call("login", authentication);
       
       	   authKey = login.getComposedValue("loginResponse").getStringValue("loginReturn");
       } catch (FaultResponseException e) {
          if (e.fault.getComposedValue("detail").getChildrenKeys()
              .contains("com.atlassian.jira.rpc.exception.RemoteAuthenticationException")) {
       	      System.err.println("wrong login or password !");
	      System.exit(1);
	  } else {
            throw e;
       	}
       }
       ComposedValue query = new ComposedValue();
       query.put("in0", authKey);
       query.put("in1", "10093");
       
       ComposedValue result = client.call("getIssuesFromFilter", query);
       
       System.out.println(result); //this will show you issues matching jira filter 10093
    }
}

Second: download the last version of SOAP-dust

SOAP-dust is currently released under version 0.1.129 and is available here.

Third: Compile your client

  $> javac -cp soap-dust-0.1.129.jar QueryJiraWithSoapdust.java

Fourth: Run your client

$> java -cp soap-dust-0.1.129.jar:. QueryJiraWithSoapdust
wrong login or password !

That's it !

OK... it would display a nicer output with a valid login/password. Do you really want to open an account on jira.codehaus.org ?

And remember: your application depends of only a single jar. Useless but so fun: compare with the cxf dependency graph.