from("timer:swiftTest?repeatCount=1")//timer, auto start, only repeat once .beanRef("SWIFTTestService","process")//retrieve some messages # .split(body())//split 4 message # into 4 runs, no parrallel processing .beanRef("SWIFTTestService","retrieveMsg") //retrieve the message through org.openqa.selenium.WebDriver .to("xslt:swiftTransformer.xsl") //XSLT, transform the XML .beanRef("SWIFTTestService","aggregateMsg") //aggregate the parsed XMLs, and put those into instance variable, for passing to Email .to("file:output?fileName=SwiftMessages-${header.messageId}.xml")//write the parsed XML into output folder .log("gcom swift msg result: "+body().toString()) .end() .beanRef("SWIFTTestService","emailMsg")//Email the aggregated parsed XML as attachments .log("gcom swift msg result: "+body().toString())
Retrieve the message through org.openqa.selenium.WebDriver
@PostConstruct public void webDriverInit() { driver.get("https://website"); // // Find the text input element by its name WebElement username = driver.findElement(By.name("xxxxxxx_username")); username.clear(); username.sendKeys(user); WebElement password = driver.findElement(By.name("xxxxx_password")); password.clear(); password.sendKeys(pwd); driver.findElement(By.name("Logon")).click(); parsedGXML = new ArrayList<String>(); } public String retrieveMsg(Exchange exchange) throws InterruptedException{ driver.get("https://xxxxxxxxxxxx"); //publisher:clear WebElement publisher = driver.findElement(By.name("xxx")); //publisher.clear(); publisher.sendKeys("xxxxx"); driver.findElement(By.xpath("//input[@type='submit' and @value='Search']")).click(); (new WebDriverWait(driver, 60)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return !driver.findElements(By.xpath("//a[text()='xxxxxxxx']")).isEmpty(); } }); driver.findElement(By.xpath("//a[text()='xxxxxxx']")).click(); String swiftMsg = driver.findElement(By.xpath("//form[@id='message' and @method='post']/pre")).getText(); }
Email using javax.mail package.
Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); int i=0; for(String transformedSwiftMsg: transformedSwiftMsgs) { i++; BodyPart attachmentBodyPart = new MimeBodyPart(); DataSource ds = new ByteArrayDataSource(transformedSwiftMsg.getBytes("UTF-8"), "application/xml"); attachmentBodyPart.setDataHandler(new DataHandler(ds)); attachmentBodyPart.setFileName("SwiftMsg-"+i+".xml"); multipart.addBodyPart(attachmentBodyPart); } msg.setContent(multipart,"text/html");