Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- try {
- File fXmlFile = new File("facturae_tpl_firmada.xml");
- byte[] base64Xml = Base64.getEncoder().encode(cargarArchivo(fXmlFile));
- String base64XmlStr = new String(base64Xml);
- File xmlRequest = new File("tx_request_template.xml");
- DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
- dbFactory.setNamespaceAware(true);
- DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
- Document document = dBuilder.parse(xmlRequest);
- document.getElementsByTagName("dss:Base64XML").item(0).setTextContent(base64XmlStr);
- MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
- SOAPMessage msg = mf.createMessage();
- msg.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true");
- SOAPPart soapPart = msg.getSOAPPart();
- SOAPBody soapBody = msg.getSOAPBody();
- SOAPEnvelope envelope = soapPart.getEnvelope();
- SOAPHeader header = msg.getSOAPHeader();
- header.detachNode();
- soapBody.addDocument(document);
- msg.getMimeHeaders().addHeader("SOAPAction", "verify");
- msg.getMimeHeaders().addHeader("Content-Type", "text/xml");
- msg.saveChanges();
- sendSoapRequest("https://uoc.safelayer.com:8080/trustedx-gw/SoapGateway", msg);
- } catch(Exception e) {
- System.out.println(e.getMessage());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement