package com.iflytek; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; public class ssodemo { public static void main(String[] args) throws Exception { //cas server 校验地址 String serverValidateUrl="https://demo.tch.com:8443/cas/serviceValidate"; //客户端地址 String service = "http://app1.tch.com:18080/examples/servlets/servlet/HelloWorldExample"; //ticket String ticket ="ST-7-gCMvfsyy9hmnadayB1e3-cas01.example.org"; //组装url String constructServiceUrl = serverValidateUrl+"?ticket="+ticket+"&service="+service; System.out.println("constructServiceUrl:"+constructServiceUrl); URL url =new URL(constructServiceUrl); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setConnectTimeout(5*1000); conn.setRequestMethod("GET"); InputStream inStream = conn.getInputStream(); final StringBuilder builder = new StringBuilder(255); int byteRead; while ((byteRead = inStream.read()) != -1) { builder.append((char) byteRead); } String response = builder.toString(); System.out.print("response:"+response); } }