| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- package xin.glue.user.common;
- import javax.net.ssl.HttpsURLConnection;
- import com.alibaba.fastjson.JSON;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.io.OutputStreamWriter;
- import java.net.HttpURLConnection;
- import java.net.URI;
- import java.net.URISyntaxException;
- import java.net.URL;
- import java.net.URLConnection;
- public class UIJ030054 {
- public HttpURLConnection createConnection(URI uri) throws IOException {
- URL url = uri.toURL();
- URLConnection connection = url.openConnection();
- HttpsURLConnection httpsURLConnection = (HttpsURLConnection) connection;
- httpsURLConnection.setSSLSocketFactory(new UIJ030053());
- return httpsURLConnection;
- }
-
- public static void main(String[] args) {
-
- UIJ030052 uij030052 = new UIJ030052();
- String cod1,cod2;
- String asd=uij030052.jsonPost("http://172.16.0.49/xg56/webservice/mesWaybillService/queryIsLock/20181213S268", "20181204S116");
- int loc=asd.indexOf("IS_LOCK");
- int loc1=asd.indexOf("RET_CODE");
- cod1=asd.substring(loc1+11, loc1+12);
- cod2=asd.substring(loc+10, loc+11);
- UIJ030054 httpsUrlConnectionMessageSender = new UIJ030054();
- String loginUrl = "https://218.87.96.132/xg56/webservice/mesWaybillService/queryIsLock/20181127S010";
- //String data = "username=xiaomi&password=Ultrasafe_123";
- HttpURLConnection connection;
- try {
- connection = httpsUrlConnectionMessageSender.createConnection(new URI(loginUrl ));
- connection.setDoOutput(true);
- connection.setDoInput(true);
- connection.setRequestMethod("POST");
- connection.setUseCaches(false);
- connection.setInstanceFollowRedirects(true);
- connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
- connection.connect();
- //POSTÇëÇó
- OutputStreamWriter os = null;
- String json="";
- // os = new OutputStreamWriter(connection.getOutputStream());
- // os.write(data);
- // os.flush();
- json=getResponse(connection);
- System.out.println(json);
-
- if (connection != null) {
- connection.disconnect();
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (URISyntaxException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public static String getResponse(HttpURLConnection Conn) throws IOException {
- InputStream is;
- if (Conn.getResponseCode() >= 400) {
- is = Conn.getErrorStream();
- } else {
- is = Conn.getInputStream();
- }
- String response = "";
- byte buff[] = new byte[512];
- int b = 0;
- while ((b = is.read(buff, 0, buff.length)) != -1) {
- response += new String(buff, 0, b);
- }
- is.close();
- System.out.println(response);
- return response;
- }
- }
|