winghown 发表于 2013-6-25 08:50
把你的代码贴出来看看
// 获取Servlet连接并设置请求的方法 String url = “http://10.7.3.225:8080/service/XchangeServlet”; URL realURL = new URL(url); HttpURLConnection connection = (HttpURLConnection)realURL.openConnection(); connection.setDoOutput(true); connection.setRequestProperty(“Contect-type”, “text/xml”); connection.setRequestMethod(“Post”); // 将Document对象写入连接的输出流中 File file = new File(“C:/samples/psndoc.xml”); InputStream input = new FileInputStream(file); Document doc =XMLUtil.getDocumentBuilder().parse(input); Writer writer = new OutputStreamWriter(connection.getOutputStream(), “UTF-8”); XMLUtil.printDOMTree(writer, doc, 1); // 按照XML文件格式输出 // 从连接的输入流中取得回执信息 InputStream inputStream = connection.getInputStream(); Document resDoc = XMLUtil.getDocumentBuilder().parse(inputStream); // 解析为Doc对象 // 对回执结果的后续处理 …
|