人见有分,免费信息查询服务的地址(比如:天气预报的webservice) 免费信息查询服务的地址(比如:天气预报的webservice)这类的都可以,比如股票查询啦,路线查询啦,位置查询啦,或是兄弟们觉得有创意的查询服务都可以上来说说,最好有提供的网址,免费更好只要回答的都有分,分不够我再加! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/u/20081217/13/5a9075fc-feb1-4cde-96ac-5f982f7a1b7b.html这个我年初试过可以用 http://www.webxml.com.cn/zh_cn/web_services.aspx我看到这里有好多 到现在都没接触过webservice,我就不凑热闹了 package com.siroinfo.business;import java.io.InputStream;import java.io.OutputStream;import java.io.OutputStreamWriter;import java.net.URL;import java.net.URLConnection;import javax.xml.parsers.DocumentBuilder;import javax.xml.parsers.DocumentBuilderFactory;import org.w3c.dom.Document;import org.w3c.dom.Node;import org.w3c.dom.NodeList;public class WeatherReport {/*** 获取SOAP的请求头,并替换其中的标志符号为用户输入的城市* * 编写者:王景辉* * @param city* 用户输入的城市名称* @return 客户将要发送给服务器的SOAP请求*/private static String getSoapRequest(String city) { StringBuilder sb = new StringBuilder(); sb .append("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " + "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "<soap:Body> <getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">" + "<theCityName>" + city + "</theCityName> </getWeatherbyCityName>" + "</soap:Body></soap:Envelope>"); return sb.toString();}/*** 用户把SOAP请求发送给服务器端,并返回服务器点返回的输入流* * 编写者:王景辉* * @param city* 用户输入的城市名称* @return 服务器端返回的输入流,供客户端读取* @throws Exception*/private static InputStream getSoapInputStream(String city) throws Exception { try { String soap = getSoapRequest(city); if (soap == null) { return null; } URL url = new URL( "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"); URLConnection conn = url.openConnection(); conn.setUseCaches(false); conn.setDoInput(true); conn.setDoOutput(true); conn.setRequestProperty("Content-Length", Integer.toString(soap .length())); conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); conn.setRequestProperty("SOAPAction", "http://WebXml.com.cn/getWeatherbyCityName"); OutputStream os = conn.getOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8"); osw.write(soap); osw.flush(); osw.close(); InputStream is = conn.getInputStream(); return is; } catch (Exception e) { e.printStackTrace(); return null; }}/*** 对服务器端返回的XML进行解析* * 编写者:王景辉* * @param city* 用户输入的城市名称* @return 字符串 用,分割*/public static String getWeather(String city) { try { Document doc; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); DocumentBuilder db = dbf.newDocumentBuilder(); InputStream is = getSoapInputStream(city); doc = db.parse(is); NodeList nl = doc.getElementsByTagName("string"); StringBuffer sb = new StringBuffer(); for (int count = 0; count < nl.getLength(); count++) { Node n = nl.item(count); if(n.getFirstChild().getNodeValue().equals("查询结果为空!")) { sb = new StringBuffer("#") ; break ; } sb.append(n.getFirstChild().getNodeValue() + "#\n"); } is.close(); return sb.toString(); } catch (Exception e) { e.printStackTrace(); return null; }}public static String getByCity(String city){ String[] strs = WeatherReport.getWeather(city).split("#"); StringBuffer sb = new StringBuffer() ; sb.append(strs[6].split(" ")[1].trim()).append(",").append(strs[5].replaceAll("\n","")); return sb.toString() ;}/**℃* 测试用* @param args* @throws Exception*/public static void main(String[] args) throws Exception { System.out.println(getByCity("杭州"));}} http://www.weathercn.com/maps/tunew.jsp http://www.51766.com/www/traffic/search_train.jsp http://topic.csdn.net/u/20081217/13/5a9075fc-feb1-4cde-96ac-5f982f7a1b7b.html http://topic.csdn.net/u/20081217/13/5a9075fc-feb1-4cde-96ac-5f982f7a1b7b.html不错! google日历有开放的api可以直接用,实现你说的功能不成问题 JSP技术群希望广大朋友加入一起学习,群号:93722377 可以容200人! http://topic.csdn.net/u/20081217/13/5a9075fc-feb1-4cde-96ac-5f982f7a1b7b.html JSP做的WEB网游原理 java刚学了,也就是能过个scjp的水平,会asp应该看什么书学jsp? http报文头 在线跪求:jsp页面无法显示问题! 关于邮件地址验证,为什么我运行这段程序永远返回false apache运行问题? linux jxl 严重消耗内存,造成整个系统卡死状态 请问这是什么错误?该如何解决?在线等…… ssh出的严重错误 用java如何实现论坛的消息互发 hibernate3查询问题 java web项目中cookie中的值删除后不能立即生效
这个我年初试过可以用
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;public class WeatherReport {
/**
* 获取SOAP的请求头,并替换其中的标志符号为用户输入的城市
*
* 编写者:王景辉
*
* @param city
* 用户输入的城市名称
* @return 客户将要发送给服务器的SOAP请求
*/
private static String getSoapRequest(String city) {
StringBuilder sb = new StringBuilder();
sb
.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+ "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+ "<soap:Body> <getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
+ "<theCityName>" + city
+ "</theCityName> </getWeatherbyCityName>"
+ "</soap:Body></soap:Envelope>");
return sb.toString();
}/**
* 用户把SOAP请求发送给服务器端,并返回服务器点返回的输入流
*
* 编写者:王景辉
*
* @param city
* 用户输入的城市名称
* @return 服务器端返回的输入流,供客户端读取
* @throws Exception
*/
private static InputStream getSoapInputStream(String city) throws Exception {
try {
String soap = getSoapRequest(city);
if (soap == null) {
return null;
}
URL url = new URL(
"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx");
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true); conn.setRequestProperty("Content-Length", Integer.toString(soap
.length()));
conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8");
conn.setRequestProperty("SOAPAction",
"http://WebXml.com.cn/getWeatherbyCityName"); OutputStream os = conn.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os, "utf-8");
osw.write(soap);
osw.flush();
osw.close(); InputStream is = conn.getInputStream();
return is;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}/**
* 对服务器端返回的XML进行解析
*
* 编写者:王景辉
*
* @param city
* 用户输入的城市名称
* @return 字符串 用,分割
*/
public static String getWeather(String city) {
try {
Document doc;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
InputStream is = getSoapInputStream(city);
doc = db.parse(is);
NodeList nl = doc.getElementsByTagName("string");
StringBuffer sb = new StringBuffer();
for (int count = 0; count < nl.getLength(); count++) {
Node n = nl.item(count);
if(n.getFirstChild().getNodeValue().equals("查询结果为空!")) {
sb = new StringBuffer("#") ;
break ;
}
sb.append(n.getFirstChild().getNodeValue() + "#\n");
}
is.close();
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}public static String getByCity(String city)
{
String[] strs = WeatherReport.getWeather(city).split("#");
StringBuffer sb = new StringBuffer() ;
sb.append(strs[6].split(" ")[1].trim()).append(",").append(strs[5].replaceAll("\n",""));
return sb.toString() ;
}
/**℃
* 测试用
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
System.out.println(getByCity("杭州"));
}
}
不错!