外部系统xml数据发送至NC
来源:互联网 发布:mirrorlink认证软件 编辑:程序博客网 时间:2024/06/02 06:14
在做外部系统xml数据发送至NC的测试中,按照用友给的示例代码,出现了一些错误。
首先是找不到XMLUtil这个类。后来,用解压软甲打开NC系统安装包(170几兆)中的setup.jar文件,在NCCACHE/server3_D--ufsoft-nchome_80/CODE/lib中找到basic.jar,XMLUtil这个类就在里面。将basic.jar解压出来,在eclipse中,右击项目>build path>add extra archives>选择basic.jar。回到eclipse 代码编辑界面中,import nc.vo.jcom.xml.XMLUtil;
但是,回执信息却提示 从输入流转换Document出错。后来,使用jdom(版本2.0.6,跟上面的basic.jar一样,需要导入)来处理终于可以了:
主要问题在示例代码中的("content-type", "text/xml");而不是("contect-type", "text/xml");其次是XMLUtil.printDOMTree(writer, doc, 1);这个printDOMTree根本没用。注意:doc是org.w3c.dom.Document的Document类,而上面代码中的new DOMBuilder().build(doc)返回的是JDOM中的Document类
首先是找不到XMLUtil这个类。后来,用解压软甲打开NC系统安装包(170几兆)中的setup.jar文件,在NCCACHE/server3_D--ufsoft-nchome_80/CODE/lib中找到basic.jar,XMLUtil这个类就在里面。将basic.jar解压出来,在eclipse中,右击项目>build path>add extra archives>选择basic.jar。回到eclipse 代码编辑界面中,import nc.vo.jcom.xml.XMLUtil;
但是,回执信息却提示 从输入流转换Document出错。后来,使用jdom(版本2.0.6,跟上面的basic.jar一样,需要导入)来处理终于可以了:
</pre><pre name="code" class="java">import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.InputStream;import java.io.OutputStreamWriter;import java.net.HttpURLConnection;import java.net.URL;import org.jdom2.input.DOMBuilder;import org.jdom2.input.SAXBuilder;import org.jdom2.output.XMLOutputter;import org.w3c.dom.Document;import nc.vo.jcom.xml.XMLUtil;public class XDTest {public static void main(String[] args) {String url = ".........";URL realURL;try {realURL = new URL(url);HttpURLConnection connection = (HttpURLConnection) realURL.openConnection();connection.setDoOutput(true);connection.setRequestProperty("content-type", "text/xml");connection.setRequestMethod("POST");// 将Document对象写入连接的输出流中File file = new File("C:/Users/wuqingyi/Desktop/凭证.xml");InputStream input = new FileInputStream(file);Document doc = XMLUtil.getDocumentBuilder().parse(input);// // 构造器SAXBuilder saxBuilder = new SAXBuilder();// // 设定格式XMLOutputter out = new XMLOutputter();///////////////////////////////////////注意这里,doc需要转换成JDOM的Document类/////////////////////////////////out.output(new DOMBuilder().build(doc), connection.getOutputStream());// 从连接的输入流中取得回执信息InputStream inputStream = connection.getInputStream();org.jdom2.Document jDoc = saxBuilder.build(inputStream);out.output(jDoc, new OutputStreamWriter(new FileOutputStream(new File("C:/Users/wuqingyi/Desktop/ret.xml")),"UTF-8"));} catch (Exception e1) {e1.printStackTrace();}}}
主要问题在示例代码中的("content-type", "text/xml");而不是("contect-type", "text/xml");其次是XMLUtil.printDOMTree(writer, doc, 1);这个printDOMTree根本没用。注意:doc是org.w3c.dom.Document的Document类,而上面代码中的new DOMBuilder().build(doc)返回的是JDOM中的Document类
0 0
- 外部系统xml数据发送至NC
- nc 系统 发送 XML
- NC 5.X 发送XML文件
- android客户端发送XML数据至服务器
- XMLHTTP 发送 XML 数据
- HTTP请求发送XML数据
- HTTP请求发送XML数据
- 向Internet发送xml数据
- POST方式发送XML数据
- 向Internet发送xml数据
- 发送XML数据到服务器
- 向Internet发送xml数据
- 发送xml数据给服务器
- NC查数据字典
- nc前台数据交互
- nc 数据访问接口
- 使用nc传输数据
- NC数据字典
- Java中把JSON和List结果集互转的代码片段整理
- MySQL基础教程(存储过程) 常用函数详解(日期函数、时间函数和字符串函数)
- 《JavaScript DOM 编程艺术》读书笔记
- ISLR读书笔记(1)统计学习简介
- 文章标题
- 外部系统xml数据发送至NC
- how to open ubuntu port like 8443
- 点击cell动态改变cell高度
- OVS-DPDK VM出现 virtio_net virtio4: output.0:id 30 is not a head 问题 dpdk-vhost bug fix
- 变态跳台阶
- 机器学习之决策树
- 树形问题--奶牛大集会
- 初窥Dubbo
- UE4 Unreal 界面 主题 更改