Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/RunCreationService/src/runcreationservice/Main.java @ 6151

Last change on this file since 6151 was 6151, checked in by bfarka, 13 years ago

added util for accessing service #1441

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