• 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

  • 相关阅读:
    C#如何释放未托管资源
    C# 如何将一个List转换为只读的
    【转载】所谓爱情不是一个人的事情(爱情不完全手册)
    vbs SendKey 用法 Sendkey 键盘对应的码表
    PowerShell签名和执行策略
    IDisposable接口和析构函数的联合使用
    [读报]2009中国基金业明星基金奖揭晓
    【读书笔记】泛型接口 和 泛型方法
    C# 反射(转)
    设计模式详解——装饰者模式
  • 原文地址:https://www.cnblogs.com/passerlee/p/14957869.html
Copyright © 2020-2023  润新知