1 | /* |
---|
2 | * To change this template, choose Tools | Templates |
---|
3 | * and open the template in the editor. |
---|
4 | */ |
---|
5 | package runcreationservice; |
---|
6 | |
---|
7 | import com.heuristiclab.services.runcreation.RunCreationService; |
---|
8 | import com.heuristiclab.services.runcreation.Algorithm; |
---|
9 | import com.heuristiclab.services.runcreation.ArrayOfAlgorithm; |
---|
10 | import com.heuristiclab.services.runcreation.IRunCreationService; |
---|
11 | import java.net.MalformedURLException; |
---|
12 | import java.net.URL; |
---|
13 | import java.security.KeyManagementException; |
---|
14 | import java.security.NoSuchAlgorithmException; |
---|
15 | import java.util.logging.Level; |
---|
16 | import java.util.logging.Logger; |
---|
17 | import javax.net.ssl.HttpsURLConnection; |
---|
18 | import javax.net.ssl.SSLContext; |
---|
19 | import javax.net.ssl.TrustManager; |
---|
20 | import javax.net.ssl.X509TrustManager; |
---|
21 | |
---|
22 | /** |
---|
23 | * |
---|
24 | * @author MartinH |
---|
25 | */ |
---|
26 | public class Main { |
---|
27 | |
---|
28 | static { |
---|
29 | // Create a trust manager that does not validate certificate chains |
---|
30 | TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { |
---|
31 | |
---|
32 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { |
---|
33 | return new java.security.cert.X509Certificate[]{}; |
---|
34 | } |
---|
35 | |
---|
36 | public void checkClientTrusted( |
---|
37 | java.security.cert.X509Certificate[] certs, String authType) { |
---|
38 | } |
---|
39 | |
---|
40 | public void checkServerTrusted( |
---|
41 | java.security.cert.X509Certificate[] certs, String authType) { |
---|
42 | } |
---|
43 | }}; |
---|
44 | |
---|
45 | SSLContext sc; |
---|
46 | try { |
---|
47 | sc = SSLContext.getInstance("SSL"); |
---|
48 | sc.init(null, trustAllCerts, new java.security.SecureRandom()); |
---|
49 | HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); |
---|
50 | } catch (NoSuchAlgorithmException e) { |
---|
51 | throw new RuntimeException(e); |
---|
52 | } catch (KeyManagementException e) { |
---|
53 | throw new RuntimeException(e); |
---|
54 | } |
---|
55 | |
---|
56 | } |
---|
57 | |
---|
58 | public void GetAlgorithmsTest() { |
---|
59 | try { |
---|
60 | RunCreationService srv = new RunCreationService(new URL("https://services.heuristiclab.com/OKB.SPR.Java-3.3/RunCreationService.svc?wsdl")); |
---|
61 | IRunCreationService port = srv.getRunCreationService(); |
---|
62 | ArrayOfAlgorithm algos = port.getAlgorithms("HeuristicLab 3.3"); //Unknown"); |
---|
63 | for (Algorithm algo : algos.getAlgorithm()) { |
---|
64 | System.out.println("algo Id:=" + algo.getId()); |
---|
65 | System.out.println("algo AlgorithmClass:=" + algo.getAlgorithmClass()); |
---|
66 | System.out.println("algo DataType:=" + algo.getDataType()); |
---|
67 | System.out.println("algo Class:=" + algo.getClass()); |
---|
68 | System.out.println("algo Description:=" + algo.getDescription().getValue()); |
---|
69 | System.out.println("algo Name:=" + algo.getName().getValue()); |
---|
70 | } |
---|
71 | //assertTrue("No Algorithms found!", algos.getAlgorithm().size() > 0); |
---|
72 | //assertTrue("No Algorithms found!", algos.getAlgorithm().size() > 0); |
---|
73 | } catch (MalformedURLException ex) { |
---|
74 | Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | /** |
---|
79 | * @param args the command line arguments |
---|
80 | */ |
---|
81 | public static void main(String[] args) { |
---|
82 | Main test = new Main(); |
---|
83 | test.GetAlgorithmsTest(); |
---|
84 | } |
---|
85 | } |
---|