| | |
| | | if (response.isSuccessful() && response.body() != null) { |
| | | String bodyStr = response.body().string(); |
| | | |
| | | String innerXml = extractCdata(bodyStr); |
| | | if (innerXml == null) throw new RuntimeException("No CDATA <document> found in response"); |
| | | String evCode = extractEvCode(bodyStr); |
| | | if (!"Y".equalsIgnoreCase(evCode)) { |
| | | throw new RuntimeException("SOAP business failed, EV_CODE: " + evCode); |
| | | } |
| | | |
| | | String decodedXml = decodeXmlEntities(innerXml); |
| | | String decodedXml = decodeXmlEntities(bodyStr); |
| | | |
| | | String innerXml = extractCdata(decodedXml); |
| | | if (innerXml == null) throw new RuntimeException("No CDATA <document> found in response"); |
| | | |
| | | JAXBContext context = JAXBContext.newInstance(BizDocumentResult.class); |
| | | Unmarshaller unmarshaller = context.createUnmarshaller(); |
| | |
| | | .method("POST", body) |
| | | // .addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)") |
| | | .addHeader("Content-Type", "application/xml") |
| | | .addHeader("Authorization", "Basic UkZDWkpYSUFPQlU6cHBCOVIhSGU=") |
| | | .addHeader("Authorization", "Basic ") |
| | | .addHeader("Accept", "*/*") |
| | | .addHeader("Host", "mipoq.p.mi.com") |
| | | .addHeader("Connection", "keep-alive") |
| | |
| | | return client.newCall(request).execute(); |
| | | } |
| | | |
| | | private String extractCdata(String xml) { |
| | | int cdataStart = xml.indexOf("<![CDATA["); |
| | | int cdataEnd = xml.indexOf("]]>", cdataStart); |
| | | if (cdataStart == -1 || cdataEnd == -1) return null; |
| | | return xml.substring(cdataStart + 9, cdataEnd).trim(); |
| | | private String extractEvCode(String xml) { |
| | | int start = xml.indexOf("<EV_CODE>"); |
| | | int end = xml.indexOf("</EV_CODE>", start); |
| | | if (start == -1 || end == -1) return null; |
| | | return xml.substring(start + 9, end).trim(); |
| | | } |
| | | |
| | | private String decodeXmlEntities(String xml) { |
| | |
| | | .replace(">", ">") |
| | | .replace("&", "&"); |
| | | } |
| | | |
| | | private String extractCdata(String xml) { |
| | | int cdataStart = xml.indexOf("<EV_RESULT>"); |
| | | int cdataEnd = xml.indexOf("</EV_RESULT>", cdataStart); |
| | | if (cdataStart == -1 || cdataEnd == -1) return null; |
| | | return xml.substring(cdataStart + 11, cdataEnd).trim(); |
| | | } |
| | | } |