List of usage examples for java.net URL URL
public URL(String spec) throws MalformedURLException
From source file:io.fabric8.apiman.gateway.ApimanGatewayStarter.java
/** * Main entry point for the Apiman Gateway micro service. * @param args the arguments/* w ww .j a v a 2s. co m*/ * @throws Exception when any unhandled exception occurs */ public static final void main(String[] args) throws Exception { String isTestModeString = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_TESTMODE, "false"); boolean isTestMode = "true".equalsIgnoreCase(isTestModeString); if (isTestMode) log.info("Apiman Gateway Running in TestMode"); String isSslString = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_SSL, "false"); isSsl = "true".equalsIgnoreCase(isSslString); log.info("Apiman Gateway running in SSL: " + isSsl); String protocol = "http"; if (isSsl) protocol = "https"; URL elasticEndpoint = null; File gatewayConfigFile = new File(APIMAN_GATEWAY_PROPERTIES); String esUsername = null; String esPassword = null; if (gatewayConfigFile.exists()) { PropertiesConfiguration config = new PropertiesConfiguration(gatewayConfigFile); esUsername = config.getString("es.username"); esPassword = config.getString("es.password"); if (Utils.isNotNullOrEmpty(esPassword)) esPassword = new String(Base64.getDecoder().decode(esPassword), StandardCharsets.UTF_8).trim(); setConfigProp(APIMAN_GATEWAY_ES_USERNAME, esUsername); setConfigProp(APIMAN_GATEWAY_ES_PASSWORD, esPassword); } log.info(esUsername + esPassword); // Require ElasticSearch and the Gateway Services to to be up before proceeding if (isTestMode) { URL url = new URL(protocol + "://localhost:9200"); elasticEndpoint = waitForDependency(url, "elasticsearch-v1", "status", "200", esUsername, esPassword); } else { String defaultEsUrl = protocol + "://elasticsearch-v1:9200"; String esURL = Systems.getEnvVarOrSystemProperty(APIMAN_GATEWAY_ELASTICSEARCH_URL, defaultEsUrl); URL url = new URL(esURL); elasticEndpoint = waitForDependency(url, "elasticsearch-v1", "status", "200", esUsername, esPassword); log.info("Found " + elasticEndpoint); } File usersFile = new File(APIMAN_GATEWAY_USER_PATH); if (usersFile.exists()) { setConfigProp(Users.USERS_FILE_PROP, APIMAN_GATEWAY_USER_PATH); } log.info("** ******************************************** **"); Fabric8GatewayMicroService microService = new Fabric8GatewayMicroService(elasticEndpoint); if (isSsl) { microService.startSsl(); microService.joinSsl(); } else { microService.start(); microService.join(); } }
From source file:de.jwi.ftp.FTPUploader.java
public static void main(String[] args) throws Exception { URL url = new URL("ftp://ftp:none@localhost/tmp"); String protocol = url.getProtocol(); String host = url.getHost();/* w w w . ja va2 s . c o m*/ String userInfo = url.getUserInfo(); String path = url.getPath(); String file = url.getFile(); File f = new File("D:/temp/out"); List l = new ArrayList(); l.add(f); String s = upload(url, l); System.out.println(s); int x = 5; }
From source file:io.fabric8.apiman.ApimanStarter.java
/** * Main entry point for the API Manager micro service. * @param args the arguments/* ww w . j av a 2s. c o m*/ * @throws Exception when any unhandled exception occurs */ public static final void main(String[] args) throws Exception { Fabric8ManagerApiMicroService microService = new Fabric8ManagerApiMicroService(); boolean isTestMode = getSystemPropertyOrEnvVar(APIMAN_TESTMODE, false); if (isTestMode) log.info("Apiman running in TestMode"); boolean isSsl = getSystemPropertyOrEnvVar(APIMAN_SSL, false); log.info("Apiman running in SSL: " + isSsl); String protocol = "http"; if (isSsl) protocol = "https"; File apimanConfigFile = new File(APIMAN_PROPERTIES); String esUsername = null; String esPassword = null; if (apimanConfigFile.exists()) { PropertiesConfiguration config = new PropertiesConfiguration(apimanConfigFile); esUsername = config.getString("es.username"); esPassword = config.getString("es.password"); if (Utils.isNotNullOrEmpty(esPassword)) esPassword = new String(Base64.getDecoder().decode(esPassword), StandardCharsets.UTF_8).trim(); setConfigProp(APIMAN_ELASTICSEARCH_USERNAME, esUsername); setConfigProp(APIMAN_ELASTICSEARCH_PASSWORD, esPassword); } URL elasticEndpoint = null; // Require ElasticSearch and the Gateway Services to to be up before proceeding if (isTestMode) { URL url = new URL("https://localhost:9200"); elasticEndpoint = waitForDependency(url, "", "elasticsearch-v1", "status", "200", esUsername, esPassword); } else { String defaultEsUrl = protocol + "://elasticsearch-v1:9200"; String esURL = getSystemPropertyOrEnvVar(APIMAN_ELASTICSEARCH_URL, defaultEsUrl); URL url = new URL(esURL); elasticEndpoint = waitForDependency(url, "", "elasticsearch-v1", "status", "200", esUsername, esPassword); log.info("Found " + elasticEndpoint); String defaultGatewayUrl = protocol + "://apiman-gateway:7777"; gatewayUrl = getSystemPropertyOrEnvVar(APIMAN_GATEWAY_URL, defaultGatewayUrl); URL gatewayEndpoint = waitForDependency(new URL(gatewayUrl), "/api/system/status", "apiman-gateway", "up", "true", null, null); log.info("Found " + gatewayEndpoint); } setConfigProp("apiman.plugins.repositories", "http://repo1.maven.org/maven2/"); setConfigProp("apiman-manager.plugins.registries", "http://cdn.rawgit.com/apiman/apiman-plugin-registry/1.2.6.Final/registry.json"); setFabric8Props(elasticEndpoint); if (isSsl) { microService.startSsl(); microService.joinSsl(); } else { microService.start(); microService.join(); } }
From source file:geocodingissues.Main.java
/** * @param args the command line arguments *//* ww w . j av a 2s .c om*/ public static void main(String[] args) throws JSONException { Main x = new Main(); ResultSet rs = null; x.establishConnection(); //x.addColumns(); //already did this rs = x.getLatLong(); int id; double latitude; double longitude; String req; String street_no; String street; String neighborhood; String locality; String PC; JSONObject jObject; JSONArray resultArray; JSONArray compArray; try { while (rs.next()) { id = rs.getInt("id"); latitude = rs.getDouble("latitude"); longitude = rs.getDouble("longitude"); //System.out.println("id: " + id); req = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + Double.toString(latitude) + "," + Double.toString(longitude) + "&result_type=street_address|neighborhood|locality|postal_code&key=" + key; try { URL url = new URL(req + "&sensor=false"); URLConnection conn = url.openConnection(); ByteArrayOutputStream output = new ByteArrayOutputStream(1024); IOUtils.copy(conn.getInputStream(), output); output.close(); req = output.toString(); } catch (Exception e) { System.out.println("Geocoding Error"); } if (req.contains("OVER_QUERY_LIMIT")) { System.out.println("Over Daily Query Limit"); System.exit(0); } if (!req.contains("ZERO_RESULTS")) { //System.out.println("req: "); //System.out.println(req); jObject = new JSONObject(req); resultArray = jObject.getJSONArray("results"); // Retrieve information on street address and insert into table compArray0 = resultArray.getJSONObject(0).getJSONArray("address_components"); street_no = compArray0.getJSONObject(0).getString("long_name"); street = compArray0.getJSONObject(1).getString("long_name"); x.insertValues(id, street_no, street); // Retrieve information on neighborhood and insert into table compArray1 = resultArray.getJSONObject(1).getJSONArray("address_components"); neighborhood = compArray1.getJSONObject(0).getString("long_name"); x.insertNbhd(id, neighborhood); // Retrieve information on locality and insert into table compArray2 = resultArray.getJSONObject(2).getJSONArray("address_components"); locality = compArray2.getJSONObject(0).getString("long_name"); x.insertLocality(id, locality); // Retrieve information on postal code and insert into table compArray3 = resultArray.getJSONObject(3).getJSONArray("address_components"); PC = compArray3.getJSONObject(0).getString("long_name"); x.insertPC(id, PC); } } } catch (Exception e) { System.out.println("Problem when updating the database."); } x.closeConnection(); }
From source file:com.github.vatbub.awsvpnlauncher.Main.java
public static void main(String[] args) { Common.getInstance().setAppName("awsVpnLauncher"); FOKLogger.enableLoggingOfUncaughtExceptions(); prefs = new Preferences(Main.class.getName()); // enable the shutdown hook Runtime.getRuntime().addShutdownHook(new Thread(() -> { if (session != null) { if (session.isConnected()) { session.disconnect();/* w w w.jav a2s.c o m*/ } } })); UpdateChecker.completeUpdate(args, (oldVersion, oldFile) -> { if (oldVersion != null) { FOKLogger.info(Main.class.getName(), "Successfully upgraded " + Common.getInstance().getAppName() + " from v" + oldVersion.toString() + " to v" + Common.getInstance().getAppVersion()); } }); List<String> argsAsList = new ArrayList<>(Arrays.asList(args)); for (String arg : args) { if (arg.toLowerCase().matches("mockappversion=.*")) { // Set the mock version String version = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockAppVersion(version); argsAsList.remove(arg); } else if (arg.toLowerCase().matches("mockbuildnumber=.*")) { // Set the mock build number String buildnumber = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockBuildNumber(buildnumber); argsAsList.remove(arg); } else if (arg.toLowerCase().matches("mockpackaging=.*")) { // Set the mock packaging String packaging = arg.substring(arg.toLowerCase().indexOf('=') + 1); Common.getInstance().setMockPackaging(packaging); argsAsList.remove(arg); } } args = argsAsList.toArray(new String[0]); try { mvnRepoConfig = new Config( new URL("https://www.dropbox.com/s/vnhs4nax2lczccf/mavenRepoConfig.properties?dl=1"), Main.class.getResource("mvnRepoFallbackConfig.properties"), true, "mvnRepoCachedConfig", true); projectConfig = new Config( new URL("https://www.dropbox.com/s/d36hwrrufoxfmm7/projectConfig.properties?dl=1"), Main.class.getResource("projectFallbackConfig.properties"), true, "projectCachedConfig", true); } catch (IOException e) { FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not load the remote config", e); } try { installUpdates(args); } catch (Exception e) { FOKLogger.log(Main.class.getName(), Level.SEVERE, "Could not install updates", e); } if (args.length == 0) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } switch (args[0].toLowerCase()) { case "setup": setup(); break; case "launch": initAWSConnection(); launch(); break; case "terminate": initAWSConnection(); terminate(); break; case "config": // require a second arg if (args.length == 2) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } config(Property.valueOf(args[1]), args[2]); break; case "getconfig": // require a second arg if (args.length == 1) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } getConfig(Property.valueOf(args[1])); break; case "printconfig": printConfig(); break; case "deleteconfig": // require a second arg if (args.length == 1) { // not enough arguments printHelpMessage(); throw new NotEnoughArgumentsException(); } deleteConfig(Property.valueOf(args[1])); break; case "ssh": String sshInstanceId; if (args.length == 2) { // a instanceID is specified sshInstanceId = args[1]; } else { String instanceIdsPrefValue = prefs.getPreference("instanceIDs", ""); if (instanceIdsPrefValue.equals("")) { throw new NotEnoughArgumentsException( "No instanceId was specified to connect to and no instanceId was saved in the preference file. Please either start another instance using the launch command or specify the instance id of the instance to connect to as a additional parameter."); } List<String> instanceIds = Arrays.asList(instanceIdsPrefValue.split(";")); if (instanceIds.size() == 1) { // exactly one instance found sshInstanceId = instanceIds.get(0); } else { FOKLogger.severe(Main.class.getName(), "Multiple instance ids found:"); for (String instanceId : instanceIds) { FOKLogger.severe(Main.class.getName(), instanceId); } throw new NotEnoughArgumentsException( "Multiple instance ids were found in the preference file. Please specify the instance id of the instance to connect to as a additional parameter."); } } initAWSConnection(); ssh(sshInstanceId); break; default: printHelpMessage(); } }
From source file:PropertiesUtil.java
public static void main(String args[]) { try {/*from w w w. j a v a 2 s .com*/ System.out.println(load(new Properties(), "C:/data/ccm_wa/dordev/Countrywide~csdrzs/Countrywide/src/com/javelin/util/test.properties")); System.out.println(load(new Properties(), new File( "C:/data/ccm_wa/dordev/Countrywide~csdrzs/Countrywide/src/com/javelin/util/test.properties"))); System.out.println(load(new Properties(), new URL( "file:///C:/data/ccm_wa/dordev/Countrywide~csdrzs/Countrywide/src/com/javelin/util/test.properties"))); System.out.println(load(new Properties(), PropertiesUtil.class, "test.properties")); Properties properties = new Properties(); properties.put("1", "2"); properties.put("2", "2"); properties.put("3", "3"); store(properties, "C:/data/ccm_wa/dordev/Countrywide~csdrzs/Countrywide/src/com/javelin/util/test1.properties"); store(properties, new File( "C:/data/ccm_wa/dordev/Countrywide~csdrzs/Countrywide/src/com/javelin/util/test2.properties")); store(properties, PropertiesUtil.class, "test4.properties"); System.out.println(getByValue(properties, "2")); } catch (Exception e) { e.printStackTrace(); } }
From source file:io.druid.server.sql.SQLRunner.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "help"); options.addOption("v", false, "verbose"); options.addOption("e", "host", true, "endpoint [hostname:port]"); CommandLine cmd = new GnuParser().parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("SQLRunner", options); System.exit(2);/*from w w w .ja v a 2s.c om*/ } String hostname = cmd.getOptionValue("e", "localhost:8080"); String sql = cmd.getArgs().length > 0 ? cmd.getArgs()[0] : STATEMENT; ObjectMapper objectMapper = new DefaultObjectMapper(); ObjectWriter jsonWriter = objectMapper.writerWithDefaultPrettyPrinter(); CharStream stream = new ANTLRInputStream(sql); DruidSQLLexer lexer = new DruidSQLLexer(stream); TokenStream tokenStream = new CommonTokenStream(lexer); DruidSQLParser parser = new DruidSQLParser(tokenStream); lexer.removeErrorListeners(); parser.removeErrorListeners(); lexer.addErrorListener(ConsoleErrorListener.INSTANCE); parser.addErrorListener(ConsoleErrorListener.INSTANCE); try { DruidSQLParser.QueryContext queryContext = parser.query(); if (parser.getNumberOfSyntaxErrors() > 0) throw new IllegalStateException(); // parser.setBuildParseTree(true); // System.err.println(q.toStringTree(parser)); } catch (Exception e) { String msg = e.getMessage(); if (msg != null) System.err.println(e); System.exit(1); } final Query query; final TypeReference typeRef; boolean groupBy = false; if (parser.groupByDimensions.isEmpty()) { query = Druids.newTimeseriesQueryBuilder().dataSource(parser.getDataSource()) .aggregators(new ArrayList<AggregatorFactory>(parser.aggregators.values())) .postAggregators(parser.postAggregators).intervals(parser.intervals) .granularity(parser.granularity).filters(parser.filter).build(); typeRef = new TypeReference<List<Result<TimeseriesResultValue>>>() { }; } else { query = GroupByQuery.builder().setDataSource(parser.getDataSource()) .setAggregatorSpecs(new ArrayList<AggregatorFactory>(parser.aggregators.values())) .setPostAggregatorSpecs(parser.postAggregators).setInterval(parser.intervals) .setGranularity(parser.granularity).setDimFilter(parser.filter) .setDimensions(new ArrayList<DimensionSpec>(parser.groupByDimensions.values())).build(); typeRef = new TypeReference<List<Row>>() { }; groupBy = true; } String queryStr = jsonWriter.writeValueAsString(query); if (cmd.hasOption("v")) System.err.println(queryStr); URL url = new URL(String.format("http://%s/druid/v2/?pretty", hostname)); final URLConnection urlConnection = url.openConnection(); urlConnection.addRequestProperty("content-type", MediaType.APPLICATION_JSON); urlConnection.getOutputStream().write(StringUtils.toUtf8(queryStr)); BufferedReader stdInput = new BufferedReader( new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8)); Object res = objectMapper.readValue(stdInput, typeRef); Joiner tabJoiner = Joiner.on("\t"); if (groupBy) { List<Row> rows = (List<Row>) res; Iterable<String> dimensions = Iterables.transform(parser.groupByDimensions.values(), new Function<DimensionSpec, String>() { @Override public String apply(@Nullable DimensionSpec input) { return input.getOutputName(); } }); System.out.println( tabJoiner.join(Iterables.concat(Lists.newArrayList("timestamp"), dimensions, parser.fields))); for (final Row r : rows) { System.out.println(tabJoiner.join(Iterables.concat( Lists.newArrayList(parser.granularity.toDateTime(r.getTimestampFromEpoch())), Iterables.transform(parser.groupByDimensions.values(), new Function<DimensionSpec, String>() { @Override public String apply(@Nullable DimensionSpec input) { return Joiner.on(",").join(r.getDimension(input.getOutputName())); } }), Iterables.transform(parser.fields, new Function<String, Object>() { @Override public Object apply(@Nullable String input) { return r.getFloatMetric(input); } })))); } } else { List<Result<TimeseriesResultValue>> rows = (List<Result<TimeseriesResultValue>>) res; System.out.println(tabJoiner.join(Iterables.concat(Lists.newArrayList("timestamp"), parser.fields))); for (final Result<TimeseriesResultValue> r : rows) { System.out.println(tabJoiner.join(Iterables.concat(Lists.newArrayList(r.getTimestamp()), Lists.transform(parser.fields, new Function<String, Object>() { @Override public Object apply(@Nullable String input) { return r.getValue().getMetric(input); } })))); } } CloseQuietly.close(stdInput); }
From source file:com.hortonworks.registries.storage.tool.sql.DatabaseUserInitializer.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(Option.builder("c").numberOfArgs(1).longOpt(OPTION_CONFIG_FILE_PATH) .desc("Config file path").build()); options.addOption(Option.builder("m").numberOfArgs(1).longOpt(OPTION_MYSQL_JAR_URL_PATH) .desc("Mysql client jar url to download").build()); options.addOption(Option.builder().hasArg().longOpt(OPTION_ADMIN_JDBC_URL) .desc("JDBC url to connect DBMS via admin.").build()); options.addOption(Option.builder().hasArg().longOpt(OPTION_ADMIN_DB_USER) .desc("Admin user name: should be able to create and grant privileges.").build()); options.addOption(Option.builder().hasArg().longOpt(OPTION_ADMIN_PASSWORD) .desc("Admin user's password: should be able to create and grant privileges.").build()); options.addOption(/*w ww. jav a 2s. c o m*/ Option.builder().hasArg().longOpt(OPTION_TARGET_USER).desc("Name of target user.").build()); options.addOption( Option.builder().hasArg().longOpt(OPTION_TARGET_PASSWORD).desc("Password of target user.").build()); options.addOption( Option.builder().hasArg().longOpt(OPTION_TARGET_DATABASE).desc("Target database.").build()); CommandLineParser parser = new BasicParser(); CommandLine commandLine = parser.parse(options, args); String[] neededOptions = { OPTION_CONFIG_FILE_PATH, OPTION_MYSQL_JAR_URL_PATH, OPTION_ADMIN_JDBC_URL, OPTION_ADMIN_DB_USER, OPTION_ADMIN_PASSWORD, OPTION_TARGET_USER, OPTION_TARGET_PASSWORD, OPTION_TARGET_DATABASE }; boolean optNotFound = Arrays.stream(neededOptions).anyMatch(opt -> !commandLine.hasOption(opt)); if (optNotFound) { usage(options); System.exit(1); } String confFilePath = commandLine.getOptionValue(OPTION_CONFIG_FILE_PATH); String mysqlJarUrl = commandLine.getOptionValue(OPTION_MYSQL_JAR_URL_PATH); Optional<AdminOptions> adminOptionsOptional = AdminOptions.from(commandLine); if (!adminOptionsOptional.isPresent()) { usage(options); System.exit(1); } AdminOptions adminOptions = adminOptionsOptional.get(); Optional<TargetOptions> targetOptionsOptional = TargetOptions.from(commandLine); if (!targetOptionsOptional.isPresent()) { usage(options); System.exit(1); } TargetOptions targetOptions = targetOptionsOptional.get(); DatabaseType databaseType = findDatabaseType(adminOptions.getJdbcUrl()); Map<String, Object> conf; try { conf = Utils.readConfig(confFilePath); } catch (IOException e) { System.err.println("Error occurred while reading config file: " + confFilePath); System.exit(1); throw new IllegalStateException("Shouldn't reach here"); } String bootstrapDirPath = null; try { bootstrapDirPath = System.getProperty("bootstrap.dir"); Proxy proxy = Proxy.NO_PROXY; String httpProxyUrl = (String) conf.get(HTTP_PROXY_URL); String httpProxyUsername = (String) conf.get(HTTP_PROXY_USERNAME); String httpProxyPassword = (String) conf.get(HTTP_PROXY_PASSWORD); if ((httpProxyUrl != null) && !httpProxyUrl.isEmpty()) { URL url = new URL(httpProxyUrl); proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url.getHost(), url.getPort())); if ((httpProxyUsername != null) && !httpProxyUsername.isEmpty()) { Authenticator.setDefault(getBasicAuthenticator(url.getHost(), url.getPort(), httpProxyUsername, httpProxyPassword)); } } StorageProviderConfiguration storageProperties = StorageProviderConfiguration.get( adminOptions.getJdbcUrl(), adminOptions.getUsername(), adminOptions.getPassword(), adminOptions.getDatabaseType()); MySqlDriverHelper.downloadMySQLJarIfNeeded(storageProperties, bootstrapDirPath, mysqlJarUrl, proxy); } catch (Exception e) { System.err.println("Error occurred while downloading MySQL jar. bootstrap dir: " + bootstrapDirPath); System.exit(1); throw new IllegalStateException("Shouldn't reach here"); } try (Connection conn = getConnectionViaAdmin(adminOptions)) { DatabaseCreator databaseCreator = DatabaseCreatorFactory.newInstance(adminOptions.getDatabaseType(), conn); UserCreator userCreator = UserCreatorFactory.newInstance(adminOptions.getDatabaseType(), conn); String database = targetOptions.getDatabase(); String username = targetOptions.getUsername(); createDatabase(databaseCreator, database); createUser(targetOptions, userCreator, username); grantPrivileges(databaseCreator, database, username); } }
From source file:AIR.Common.Web.PatternUrlRewriter.java
public static void main(String[] args) { try {//from www . ja v a 2 s .c o m Pattern p = Pattern.compile( "file:///D:/DataFiles/BB_Files/tds2_airws_org/TDSCore_2013-2014/Bank-([^/]*)/Items/Item-(?<bankid>[^/]*)-(?<itemid>[^/]*)/([^/]*)"); Matcher m = p.matcher( "file:///D:/DataFiles/BB_Files/tds2_airws_org/TDSCore_2013-2014/Bank-179/Items/Item-195-6821/Item_22489_v5_rubric.xml"); URL url = new URL(m.replaceFirst( "file:///C:/AIROSE Trainer Deployments/tmp/Datafiles/Item-${bankid}-${itemid}/Item_${itemid}_v5_rubric.xml")); System.err.println(url); } catch (Exception exp) { exp.printStackTrace(); } }
From source file:net.cloudkit.enterprises.ws.SuperPassParaProxyTest.java
public static void main(String[] args) throws Exception { // CodeLists_Const???XML? // MFT2008? RMFT8ChangeReasonCode (AlphaNumber) // 001 ?/*from w w w . j av a 2s .c om*/ // 002 // 003 ? // 004 ???? // 005 ???? // 006 ?????? // 007 ???? // 008 ???? // 009 ?????? // 010 ???? // 011 ??? // 012 ? // 013 ? // 014 ? // 015 ?? // 999 // // MFT2008 RMFT8DeclareTypeCode (AlphaNumber) // MT1401 ?? // MT2401 ??? // MT5401 ?? // MT5402 ?? // MT3402 ? // MT7402 ?? // MT8401 ?? // MT8402 ?? // MT8403 ??? // MT8404 ??? // MT4401 ?? // MT4402 ?? // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // MFT2008 RMFT8DeclareTypeCodeStat (AlphaNumber) // MT1401 ?? // MT2401 ??? // MT5401 ?? // MT5402 ?? // MT3402 ? // MT7402 ?? // MT8401 ?? // MT8402 ?? // MT8403 ??? // MT8404 ??? // MT4401 ?? // MT4402 ?? // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // MFT2008 RMFT8FunctionTypeCode (AlphaNumber) // 2 // 3 // T // 5 ? // 9 ??? // 0 ??? // 11 // // MFT2008 (AlphaNumber) RMFT8ReponseTypeCode // M1 M1- // M2 M2-?? // M3 QP // 01 01-? // 02 02- // 03 03-? // 11 11- // 12 12- // 13 13-?? // T T- // D D-? // E1 E1-?? // E2 E2-? // E3 E3-?? // E4 E4-? // // ? (AlphaNumber) MasterAffirmSign // 0 // 1 ? // 2 ? // // ? ? (AlphaNumber) DeclareType // 0 // 1 // // MFT2008?? RMFT8MobileTypeCode (AlphaNumber) // MT4403 ?? // MT4404 ?? // MT4405 ?? // MT4406 ?? // // ? RMFT8MobileFuncCode (AlphaNumber) // M1 // M2 ?? // M3 QP // 2 // 3 // T // 5 ? // 9 ? // 0 (??) // 11 URL url = new URL("http://ceesb.chinaport.gov.cn/SuperPassParaProxy/Proxy_Services/SuperPass_Proxy?wsdl"); QName qname = new QName("http://www.cneport.com/webservices/superpass", "SuperPass"); Service service = Service.create(url, qname); SuperPass superPass = service.getPort(SuperPass.class); /* String serviceName = "eport.superpass.pub.para.CustomsFlagStatus"; byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">c1f4bb</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"IcCode\">8800000246746</Key><Key name=\"OperatorName\"></Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>".getBytes(); byte[] requestData = "<?xml version=\"1.0\"?>\n<CustomsFlagStatusRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<CustomsCode>5300</CustomsCode>\n</CustomsFlagStatusRequest>".getBytes(); */ // ?? String serviceName = "eport.superpass.pub.para.LoadIntoMemory"; byte[] requestContext = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?><RequestContext><Group name=\"SystemInfo\"><Key name=\"ClientId\">5300001128334</Key><Key name=\"CertNo\">b6c29b</Key><Key name=\"SaicSysNo\">618882068</Key><Key name=\"DEP_IN_CODE\">5300</Key><Key name=\"REG_CO_CGAC\">4403941436</Key><Key name=\"ENT_SEQ_NO\">000000000000063462</Key><Key name=\"SessionId\">2015-7-14</Key><Key name=\"IcCode\">8910000270086</Key><Key name=\"OperatorName\">??</Key><Key name=\"DEP_CODE_CHG\">5300</Key><Key name=\"NAME_FULL\">???</Key></Group><Group name=\"DataPresentation\"><Key name=\"SignatureAlgorithm\" /><Key name=\"EncryptAlgorithm\" /><Key name=\"CompressAlgorithm\" /></Group></RequestContext>" .getBytes(); // ? MFT8TrayType // SELECT TRAY_CODE,TRAY_NAME FROM MFT8_TRAY_TYPE ORDER BY TRAY_CODE // ??? RMFT8TransportType // SELECT CODE, NAME FROM mft8_transport_type ORDER BY CODE // ? RMFT8CustomsCode // SELECT customs_CODE, customs_NAME FROM customs ORDER BY customs_CODE // ??(CN003) RMFT8PortCode // SELECT CODE, CHNAME FROM mft8_location_name ORDER BY CODE // ? RMFT8Curr // SELECT CODE, NAME FROM MFT8_ROAD_CURR ORDER BY CODE // ? RMFT8ReceiptPlace // SELECT CODE, NAME FROM mft8_entity ORDER BY CODE // ? RMFT8CountryCode // SELECT CODE, NAME FROM mft8_country_code ORDER BY CODE // ?? RMFT8CustomStatus // SELECT CODE, NAME FROM MFT8_ROAD_CUSTOMS_STATUS ORDER BY CODE // ?? RMFT8TransPayCode // SELECT CODE, NAME FROM MFT8_ROAD_PAYMENT_METHOD ORDER BY CODE // ??(CN005) RMFT8WrapTypeCode // SELECT CODE, NAME FROM mft8_packaging ORDER BY CODE // ??? RMFT8TransLicCode // SELECT CODE, NAME FROM MFT8_CONTR_CAR_COND ORDER BY CODE // ?? RMFT8PortWorkCode // SELECT CODE, NAME FROM MFT8_HAND_INSTR ORDER BY CODE // ?? RMFT8CommunicationCode // SELECT CODE, NAME FROM mft8_communi_type ORDER BY CODE // ? RMFT8PostCode // SELECT CODE, NAME FROM mft8_post_code ORDER BY CODE // RMFT8EquipSizeCode // SELECT CODE, SHAPE,LENGTH,HEIGHT,WIDTH FROM mft8_equip_size_type ORDER BY CODE // ??? RMFT8EquipSupCode // SELECT CODE, NAME FROM MFT8_EQUIP_SUP ORDER BY CODE // ?? RMFT8EquipFullCode // SELECT CODE, NAME FROM mft8_equip_full ORDER BY CODE // ?? RMFT8EquipSealCode // SELECT CODE, NAME FROM mft8_seal_agency ORDER BY CODE // ??? RMFT8DanGoodsCode // SELECT CODE, CHNAME FROM mft8_dan_goods ORDER BY CODE // ? RMFT8CusProCode // SELECT CODE, NAME FROM mft8_cus_procedure ORDER BY CODE // ?/? RMFT8TransportSplitCode // SELECT CODE, NAME FROM mft8_indication ORDER BY CODE // ?? RMFT8DamageAreaCode // SELECT CODE, NAME FROM MFT8_DAMAGE_AREA ORDER BY CODE // ?? RMFT8DamageTypeCode // SELECT CODE, NAME FROM MFT8_DAMAGE_TYPE_DES ORDER BY CODE // IATA?(UN005) RMFT8IATACode // SELECT CODE, NAME FROM mft8_iata_code ORDER BY CODE // ????(UN009) RMFT8LocodePort // SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE // RMFT8ComplexCode // SELECT CODE_TS, G_NAME FROM complex ORDER BY CODE_TS byte[] requestData = "<?xml version=\"1.0\"?>\n<LoadIntoMemoryRequest xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n<QuerySql>SELECT CODE, NAME FROM mft8_un_locode_port ORDER BY CODE</QuerySql>\n</LoadIntoMemoryRequest>" .getBytes(); Holder<byte[]> responseData = new Holder<byte[]>(); System.out.println(new String(superPass.service(serviceName, requestContext, requestData, responseData))); // deflate DeflateCompressorInputStream gis = new DeflateCompressorInputStream( new ByteArrayInputStream(responseData.value)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int count; byte data[] = new byte[1024]; while ((count = gis.read(data, 0, 1024)) != -1) { baos.write(data, 0, count); } gis.close(); data = baos.toByteArray(); baos.flush(); baos.close(); System.out.println(new String(data)); // System.out.println(new String(responseData.value, "UTF-8")); }