Does anyboday know if it is possible to insert xml from local file in a soap request? and how to?
What I input in the editor window
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sendXml>
<arg0>file:MyXml.xml</arg2>
</sendXml>
</soapenv:Body>
</soapenv:Envelope>
What I expect in the actuall soap message:-
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<sendXml>
<arg0><MyXml>Info</MyXml></arg2>
</sendXml>
</soapenv:Body>
</soapenv:Envelope>
You can use the context.
Put a symbol that looks like this you XML:
${myFileStuff}
In a Groovy Step that is executed before this put:
BufferedReader br = null;
try {
String sCurrentLine = "";
String myFileStuff= "";
br = new BufferedReader(new FileReader("C:\\testing.txt"));
while ((sCurrentLine = br.readLine()) != null) {
myFileStuff += sCurrentLine;
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
context.setProperty("myFileStuff", myFileStuff)
I slightly modified the code example here for the file read. There are many ways to go:
http://www.mkyong.com/java/how-to-read-file-from-java-bufferedreader-example/
You can get the import statements there.