package art.servers.gost.atex5; import static art.servers.gost.atex5.RequestXML.createSOAPEnvelope; import static art.servers.gost.atex5.RequestXML.outputSOAPMessageToString; import static art.servers.gost.atex5.RequestXML.signSOAPMessage; import art.servers.gost.access.configuration.Configuration; import art.servers.gost.access.configuration.ConfigurationDetail_ATEX5; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import javax.xml.parsers.ParserConfigurationException; import javax.xml.soap.SOAPMessage; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class RequestXML_SolicitudConsultaVehiculoAtex extends RequestXML { public static String getXMLDocument(String matricula) throws Exception { // Uncomment this only when using a proxy and set correct values //System.setProperty("https.proxyHost","host"); //System.setProperty("https.proxyPort","port"); Document document = readInXMLFile(matricula); SOAPMessage message = createSOAPEnvelope(document); message = signSOAPMessage(message); //outputSOAPMessageToScreen(message); return outputSOAPMessageToString(message); } protected static Document readInXMLFile(String matricula) throws ParserConfigurationException, SAXException, IOException { Configuration configuration = ((Configuration)art.servers.gost.access.Shared.configuration); ConfigurationDetail_ATEX5 configurationATEX5 = configuration.detail.atex5; String body = ""; body = body + "\n"; body = body + "" + configurationATEX5.userIdentifier + "\n"; body = body + "" + configurationATEX5.organismIdentifier + "\n"; body = body + "" + configurationATEX5.responsibleIdentifier + "\n"; body = body + "" + configurationATEX5.version + "\n"; body = body + "\n"; body = body + "\n"; body = body + "" + matricula + "\n"; body = body + "\n"; body = body + "\n"; InputStream reader = new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8)); javax.xml.parsers.DocumentBuilderFactory dbFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); dbFactory.setNamespaceAware(true); javax.xml.parsers.DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document doc = dBuilder.parse(reader); return doc; } }