xfire webservice怎么判断能不能连上一个接口
1个回答
展开全部
URL _url = new URL(url);
HttpURLConnection httpConnection = (HttpURLConnection)_url.openConnection();
httpConnection.setReadTimeout(20000);//设置http连接的读超时,单位是毫秒
httpConnection.connect();
Client _client = new Client(httpConnection.getInputStream(), null);
_client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, String.valueOf( 20000 ));//设置发送的超时限制,单位是毫秒;
_client.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE, "true");
_client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "true");
HttpURLConnection httpConnection = (HttpURLConnection)_url.openConnection();
httpConnection.setReadTimeout(20000);//设置http连接的读超时,单位是毫秒
httpConnection.connect();
Client _client = new Client(httpConnection.getInputStream(), null);
_client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, String.valueOf( 20000 ));//设置发送的超时限制,单位是毫秒;
_client.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE, "true");
_client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE, "true");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询