zoukankan      html  css  js  c++  java
  • NC数据交换平台

    java版本代码

    //传入拼接好的xml字符串
    public String addOrUpdateBill(String xml){
    Logger.error("输入参数xml:" + xml);
    String result = null;
    String url = getUrl("datasource");//获取需要的参数
    Logger.error("url:" + url);
    if (url == null) {
    Logger.error("获取url地址错误");
    url = "http://127.0.0.1:99/service/XChangeServlet?account=develop&groupcode=01";//根据实际需求修改
    }
    URL realURL;
    try {
    realURL = new URL(url);
    HttpURLConnection connection = (HttpURLConnection) realURL.openConnection();
    connection.setDoOutput(true);
    connection.setRequestProperty("content-type", "dept/xml");
    connection.setRequestMethod("POST");
    StringReader sr = new StringReader(xml);
    InputSource is = new InputSource(sr);
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(is);
    // 设定格式
    XMLOutputter out = new XMLOutputter();
    Logger.error("processing completed,ready to send data to url:"+ url);
    out.output(new DOMBuilder().build(doc),connection.getOutputStream());
    Logger.error("send success");
    // 从连接的输入流中取得回执信息
    InputStream inputStream = connection.getInputStream();
    result = IOUtils.toString(inputStream, "UTF-8");
    Logger.error("result:" + result);
    }

    -----------------------------

    String res = (result.split("<resultcode>")[1].split("<"))[0]; if(res.equals("1")){ //...成功之后的逻辑 }else{ //...失败之后的逻辑 }
    参考:https://blog.csdn.net/kon_mio/article/details/107069607?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-6.control
    原文链接:https://blog.csdn.net/kon_mio/article/details/107069607

  • 相关阅读:
    javascript时间戳和日期字符串相互转换
    jquery两稳定版本比较~~
    原生的强大DOM选择器querySelector
    分享一个自定义的 console 类,让你不再纠结JS中的调试代码的兼容
    基于Mesos运行Spark
    chrome插件 postman 可以调用restful服务
    cassandra优秀博客集
    Cassandra监控
    Cassandra
    SecureCRT中文显示乱码的解决方法
  • 原文地址:https://www.cnblogs.com/passerlee/p/14957869.html
Copyright © 2011-2022 走看看