11 years ago
Need help in Docx file creation with Pretty print
Hi Friends
I have wrote an groovy script in soapui for .docx file creation, its working fine and printing also . But the request XML and response XML are not coming in Pretty print , its coming as a paragraph.
Please guide me..
Code:
========
import java.io.FileInputStream;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.*;
def groovy=new com.eviware.soapui.support.GroovyUtils(context)
def project=context.testCase.testSuite.project
def testStepCount= testRunner.testCase.getTestStepCount();
log.info testStepCount
def request=project.getTestSuiteAt(0).getTestCaseAt(1).getTestStepAt(4).getProperty("Request").getValue().toString()
XWPFDocument docx = new XWPFDocument(new FileInputStream("c:\\Inputparagraph.docx"));
FileOutputStream out = new FileOutputStream(new File("C:\\createparagraph00.docx"));
XWPFParagraph p2 = docx.createParagraph();
XWPFRun r2 = p2.createRun();
r2.setText(request);
docx.write(out);
out.close();
====================
At present Output is coming below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hp="HP.SOAQ.SampleApp"> <soapenv:Header/> <soapenv:Body> <hp:GetFlights> <!--Optional:--> <hp:DepartureCity>Denver</hp:DepartureCity> <!--Optional:--> <hp:ArrivalCity>London</hp:ArrivalCity> </hp:GetFlights> </soapenv:Body> </soapenv:Envelope>
================
OUTPUT SHOULD COME LIKE BELOW:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hp="HP.SOAQ.SampleApp">
<soapenv:Header/>
<soapenv:Body>
<hp:GetFlights>
<!--Optional:-->
<hp:DepartureCity>Denver</hp:DepartureCity>
<!--Optional:-->
<hp:ArrivalCity>London</hp:ArrivalCity>
</hp:GetFlights>
</soapenv:Body>
</soapenv:Envelope>
====================
Please help me out.
I have wrote an groovy script in soapui for .docx file creation, its working fine and printing also . But the request XML and response XML are not coming in Pretty print , its coming as a paragraph.
Please guide me..
Code:
========
import java.io.FileInputStream;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.*;
def groovy=new com.eviware.soapui.support.GroovyUtils(context)
def project=context.testCase.testSuite.project
def testStepCount= testRunner.testCase.getTestStepCount();
log.info testStepCount
def request=project.getTestSuiteAt(0).getTestCaseAt(1).getTestStepAt(4).getProperty("Request").getValue().toString()
XWPFDocument docx = new XWPFDocument(new FileInputStream("c:\\Inputparagraph.docx"));
FileOutputStream out = new FileOutputStream(new File("C:\\createparagraph00.docx"));
XWPFParagraph p2 = docx.createParagraph();
XWPFRun r2 = p2.createRun();
r2.setText(request);
docx.write(out);
out.close();
====================
At present Output is coming below:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hp="HP.SOAQ.SampleApp"> <soapenv:Header/> <soapenv:Body> <hp:GetFlights> <!--Optional:--> <hp:DepartureCity>Denver</hp:DepartureCity> <!--Optional:--> <hp:ArrivalCity>London</hp:ArrivalCity> </hp:GetFlights> </soapenv:Body> </soapenv:Envelope>
================
OUTPUT SHOULD COME LIKE BELOW:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:hp="HP.SOAQ.SampleApp">
<soapenv:Header/>
<soapenv:Body>
<hp:GetFlights>
<!--Optional:-->
<hp:DepartureCity>Denver</hp:DepartureCity>
<!--Optional:-->
<hp:ArrivalCity>London</hp:ArrivalCity>
</hp:GetFlights>
</soapenv:Body>
</soapenv:Envelope>
====================
Please help me out.