import org.swift.common.soap.jira.JiraSoapService;
import org.swift.common.soap.jira.JiraSoapServiceServiceLocator;
import org.swift.common.soap.jira.RemoteGroup;
import org.swift.common.soap.jira.RemoteUser;
public class ExampleClient {
private JiraSoapServiceServiceLocator fJiraSoapServiceGetter = new JiraSoapServiceServiceLocator();
private JiraSoapService fJiraSoapService = null;
private String fToken = null;
/**
* Example client using the SOAP interface, extracts list of jira-users
*
* @author Andy Brook
*/
public static void main(String[] args) throws Exception {
if (args.length == 3) {
ExampleClient ex = new ExampleClient(args[0], args[1], args[2]);
System.out.println("Connected ok.");
JiraSoapService soapy = ex.getJiraSOAPService();
String token = ex.getToken();
RemoteGroup remoteGroup = soapy.getGroup(token, "jira-users");
System.out.println("Invoked ok, found " + remoteGroup.getUsers().length + " users");
RemoteUser[] users = remoteGroup.getUsers();
for (RemoteUser user : users) {
System.out.println(user.getName() + " - " + user.getEmail());
}
System.out.println("Completed.");
} else {
System.err.println("Usage: [server] [userid] [password]");
System.exit(-1);
}
}
public ExampleClient(String server, String user, String pass) throws Exception { // yea, in a constructor
try {
String endPoint = "/rpc/soap/jirasoapservice-v2";
fJiraSoapServiceGetter.setJirasoapserviceV2EndpointAddress(server + endPoint);
fJiraSoapServiceGetter.setMaintainSession(true);
fJiraSoapService = fJiraSoapServiceGetter.getJirasoapserviceV2();
fToken = fJiraSoapService.login(user, pass);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
public String getToken() {
return fToken;
}
public JiraSoapService getJiraSOAPService() {
return fJiraSoapService;
}
}