public static String getClaimMessage(String claimkey){
String client="cndfsa";
String password="Tfadsdfsa";
String url="https://tmcnis.org/cnis/"+claimkey+".xml";
String result="";
try {
String user=client+":"+password;
//用64位编码加密账号密码
user=new BASE64Encoder().encode(user.getBytes());
URL url2=new URL(url);
HttpsURLConnection connection= (HttpsURLConnection) url2.openConnection();
//设置连接请求头信息
connection.setRequestProperty("Authorization", "Basic "+user);
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.connect();
InputStream inputStream=connection.getInputStream();
BufferedReader buffer = new BufferedReader(new InputStreamReader(inputStream));
StringBuffer bs = new StringBuffer();
String l = null;
while((l=buffer.readLine())!=null){
bs.append(l);
}
result=parsefromXML(bs.toString());
} catch (Exception e) {
return "获取商标信息失败:"+e.getMessage();
}
return result;
}
转载于:https://my.oschina.net/u/2874430/blog/730480