| | |
| | | |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.JsonNode; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.JsonObject; |
| | | import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
| | |
| | | // test1(); |
| | | |
| | | // String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_MES_005_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; |
| | | // |
| | | // String serviceUrl = "http://podqapp.cfmoto.com.cn:50200/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_MES&receiverParty=&receiverService=&interface=SI_ZPP_CF_BC_001_SYN_OUT&interfaceNamespace=http://cfmoto.com/xi/MES"; |
| | | //// String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + |
| | | //// " <soapenv:Header/>\n" + |
| | | //// " <soapenv:Body>\n" + |
| | | //// " <urn:ZPP_CF_MES_005>\n" + |
| | | //// " <!--Optional:-->\n" + |
| | | //// " <IV_WERKS>1000</IV_WERKS>\n" + |
| | | //// " <!--Optional:-->\n" + |
| | | //// " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + |
| | | //// " </urn:ZPP_CF_MES_005>\n" + |
| | | //// " </soapenv:Body>\n" + |
| | | //// "</soapenv:Envelope>"; |
| | | // String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\n" + |
| | | // " <soapenv:Header/>\n" + |
| | | // " <soapenv:Body>\n" + |
| | | // " <urn:ZPP_CF_MES_005>\n" + |
| | | // " <!--Optional:-->\n" + |
| | | // " <IV_WERKS>1000</IV_WERKS>\n" + |
| | | // " <!--Optional:-->\n" + |
| | | // " <IV_ZSCTZD>A0055577</IV_ZSCTZD>\n" + |
| | | // " </urn:ZPP_CF_MES_005>\n" + |
| | | // " <urn:ZPP_BC_001>\n" + |
| | | // " <IV_AUFNR>000010569212</IV_AUFNR>\n" + |
| | | // " <IV_VORNR>0010</IV_VORNR>\n" + |
| | | // " <IV_LMNGA>1</IV_LMNGA>\n" + |
| | | // " <IV_XMNGA>0</IV_XMNGA> \n" + |
| | | // " <IV_STATU>1</IV_STATU> \n" + |
| | | // " </urn:ZPP_BC_001>\n" + |
| | | // " </soapenv:Body>\n" + |
| | | // "</soapenv:Envelope>"; |
| | | // // HttpClient发送SOAP请求 |
| | |
| | | // InputStream is = postMethod.getResponseBodyAsStream(); |
| | | // // 获取请求结果字符串 |
| | | // String result = IOUtils.toString(is); |
| | | // String jsonStr = xmlToJSON2(result); |
| | | // Gson gson = new Gson(); |
| | | // // 将json字符串转换成对象 |
| | | // ItemList itemList = gson.fromJson(jsonStr, ItemList.class); |
| | | //// String jsonStr = xmlToJSON2(result); |
| | | //// Gson gson = new Gson(); |
| | | //// // 将json字符串转换成对象 |
| | | //// ItemList itemList = gson.fromJson(jsonStr, ItemList.class); |
| | | // System.out.println("返回结果:" + result); |
| | | // } else { |
| | | // System.out.println("错误代码:" + status + ":" + postMethod.getResponseBodyAsString()); |
| | |
| | | return etData.toString(); |
| | | } |
| | | |
| | | /** |
| | | * 方式--贰 |
| | | * 使用hutool工具包中的工具转化 |
| | | * @param xmlStr |
| | | * @return |
| | | */ |
| | | public static String xmlToJSON3(String xmlStr){ |
| | | String status = ""; |
| | | if(xmlStr.contains("EV_STATUS")){ |
| | | JSONObject jsonObject1 = cn.hutool.json.XML.toJSONObject(xmlStr, true); |
| | | |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | JsonNode rootNode = null; |
| | | try { |
| | | rootNode = objectMapper.readTree(String.valueOf(jsonObject1)); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | String evStatus = rootNode |
| | | .path("SOAP:Envelope") |
| | | .path("SOAP:Body") |
| | | .path("n0:ZPP_BC_001.Response") |
| | | .path("EV_STATUS") |
| | | .asText(); |
| | | status = evStatus; |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | } |