读书人

用java往访问web service 提供的电视节

发布时间: 2012-10-28 09:54:44 作者: rapoo

用java去访问web service 提供的电视节目预告
思路:
1 用程序去访问 web service 服务.返回 xml文件。
2 用dom 去解析xml
3 用解析后的数据 生成 html文件

访问web service 的代码




把xml解析成int[]


提取湖北省的所以电视节目

把数据转换成html的代码
public class String2Html {public static void builderHtml(String[] strS,int i,int j) throws IOException, TemplateException{//初始化freeMarkerFile file=null; file=new File("E:\\workspace\\spring2Test\\htmlTest\\");   Configuration cf=null;   cf=new Configuration();   cf.setDirectoryForTemplateLoading(file);   Template template=null;    template=cf.getTemplate("tvShow.ftl");   Map<String,String[]> root=null;    root=new HashMap<String,String[]>();   root.put("tvShow", strS);   Writer out=null;   //下面的文件名: 电视台id_频道id_时间.html     out=new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File("E:/workspace/spring2Test/htmlTest/"+i+"_"+j+"_"+".html")),"utf-8"));      template.process(root, out);}}






//这里是原始的代码,需要好好整理整理。最好用soap






1 楼 kimmking 2009-02-21 直接用webservice的工具来做岂不更好 2 楼 kulinglei 2009-02-21 谢谢kimmking ,我不知道还有这样的工具

读书人网 >Web前端

热点推荐