xfire 超时

 

 

xifre调用webservice时,超时的设置方法,不过它的缺点是不知道如何调用java object,只能调返回string的。

 

 

public class Test {
	public static void main(String[] args) throws MalformedURLException,
			Exception {
		String url = "http://localhost:8080/callLocationWS2/services/germmyWebservice?wsdl";
		URL _url = new URL(url);
		HttpURLConnection httpConnection = (HttpURLConnection) _url
				.openConnection();
		httpConnection.setReadTimeout(20 * 1000);// 设置http连接的读超时,单位是毫秒
		httpConnection.connect();
		Client _client = new Client(httpConnection.getInputStream(), null);
		_client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, String
				.valueOf(1000 * 2));// 设置发送的超时限制,单位是毫秒;
		_client
				.setProperty(CommonsHttpMessageSender.DISABLE_KEEP_ALIVE,
						"true");
		_client.setProperty(CommonsHttpMessageSender.DISABLE_EXPECT_CONTINUE,
				"true");
		Object[] results = _client.invoke("example",
				new Object[] { "hello world" });
		System.out.println(results[0]);
		// Object results = _client
		// .invoke("getStudent", new Object[] { "123321" });
		// System.out.println(results);
	}
}

 

 

 

 

 

 

 

 

 

 

http://ilexes.blog.51cto.com/705330/330891

 

http://cn-done.iteye.com/blog/1616027

 

 

你可能感兴趣的:(xfire)