import org.swift.common.soap.confluence.ConfluenceSoapService;
import org.swift.common.soap.confluence.ConfluenceSoapServiceServiceLocator;
import org.swift.common.soap.confluence.RemoteServerInfo;
public class ExampleClient {
private final ConfluenceSoapServiceServiceLocator fConfluenceSoapServiceGetter = new ConfluenceSoapServiceServiceLocator();
private ConfluenceSoapService fConfluenceSoapService = null;
private String fToken = null;
/**
* Example client using the SOAP interface, get server information
*/
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.");
ConfluenceSoapService service = ex.getConfluenceSOAPService();
String token = ex.getToken();
RemoteServerInfo info = service.getServerInfo(token);
System.out.println("Confluence version: " + info.getMajorVersion() + "." + info.getMinorVersion());
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-axis/confluenceservice-v1";
fConfluenceSoapServiceGetter.setConfluenceserviceV2EndpointAddress(server + endPoint);
fConfluenceSoapServiceGetter.setMaintainSession(true);
fConfluenceSoapService = fConfluenceSoapServiceGetter.getConfluenceserviceV2();
fToken = fConfluenceSoapService.login(user, pass);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
public String getToken() {
return fToken;
}
public ConfluenceSoapService getConfluenceSOAPService() {
return fConfluenceSoapService;
}
}