Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 6148 was 6068, checked in by mholper, 13 years ago

added RunCreationService as Netbeansproject #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
7import com.heuristiclab.services.runcreation.RunCreationService;
8import com.heuristiclab.services.runcreation.Algorithm;
9import com.heuristiclab.services.runcreation.ArrayOfAlgorithm;
10import com.heuristiclab.services.runcreation.IRunCreationService;
11import java.net.MalformedURLException;
12import java.net.URL;
13import java.security.KeyManagementException;
14import java.security.NoSuchAlgorithmException;
15import java.util.logging.Level;
16import java.util.logging.Logger;
17import javax.net.ssl.HttpsURLConnection;
18import javax.net.ssl.SSLContext;
19import javax.net.ssl.TrustManager;
20import javax.net.ssl.X509TrustManager;
21
22/**
23 *
24 * @author MartinH
25 */
26public 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}
Note: See TracBrowser for help on using the repository browser.