当前这个地址是可以通过浏览器访问的,需要在后台通过JAVA程序来访问。
import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class Test { public static void main(String[] args) throws IOException { URL reqURL = new URL( "https://wtsz.jyzq.cn/ywcl.jsp?type=l&yybdm=1100&market=Z&userName=11009341&pwd=870221&ip=3.3.3.3&serverName=jyzq.cn"); // 创建URL对象 HttpsURLConnection httpsConn = (HttpsURLConnection) reqURL .openConnection(); /* * 下面这段代码实现向Web页面发送数据,实现与网页的交互访问 httpsConn.setDoOutput(true); * OutputStreamWriter out = new * OutputStreamWriter(huc.getOutputStream(), "8859_1"); out.write( "……" * ); out.flush(); out.close(); */ // 取得该连接的输入流,以读取响应内容 InputStreamReader insr = new InputStreamReader( httpsConn.getInputStream()); // 读取服务器的响应内容并显示 int respInt = insr.read(); while (respInt != -1) { System.out.print((char) respInt); respInt = insr.read(); } } }
Output:
0##P8ZU08YAE77TFB9T4HRC93ZGBOZNSHDY
Groovy version:
import javax.net.ssl.HttpsURLConnection URL reqURL = new URL( "https://wtsz.jyzq.cn/ywcl.jsp?type=l&yybdm=1100&market=Z&userName=11009341&pwd=870221&ip=3.3.3.3&serverName=jyzq.cn"); // 创建URL对象 HttpsURLConnection httpsConn = (HttpsURLConnection) reqURL .openConnection(); /* * 下面这段代码实现向Web页面发送数据,实现与网页的交互访问 httpsConn.setDoOutput(true); * OutputStreamWriter out = new * OutputStreamWriter(huc.getOutputStream(), "8859_1"); out.write( "……" * ); out.flush(); out.close(); */ // 取得该连接的输入流,以读取响应内容 InputStreamReader insr = new InputStreamReader( httpsConn.getInputStream()); // 读取服务器的响应内容并显示 int respInt = insr.read(); while (respInt != -1) { System.out.print((char) respInt); respInt = insr.read(); } //Output: //0##NQRCHIG6G7WJWMLKI5F1ETEGINNWT44X
注意:我用的 JAVA 8 64位版本。 据说以前在 JAVA 中, 访问 HTTPS 协议是挺麻烦的。
http://blog.csdn.net/today1858/article/details/5859876
Java安全通信:HTTPS与SSL
http://www.cnblogs.com/devinzhang/archive/2012/02/28/2371631.html
时间: 2024-10-13 00:54:33