About Me

My photo
London, United Kingdom
SOA tester in London

Friday, September 23, 2011

Soapui to Jquery

import com.eviware.soapui.impl.wsdl.teststeps.*;
import com.eviware.soapui.support.XmlHolder;
import com.eviware.soapui.SoapUI
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner
import org.apache.log4j.Logger
import com.eviware.soapui.support.xml.*;


/* Clear log Start*/
// Karthi don't know how to do this !! :)
/* Clear log Done */


def operations = [];
def services = [];
def RequestA = [];
def ResponseA = [];

def xmlUtils = new com.eviware.soapui.support.xml.XmlUtils();

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
def responseHolder = groovyUtils.getXmlHolder("getCommunication#Response");
responseHolder.namespaces["ns1"] ="http://www.apache.org/ode/pmapi"
responseHolder.namespaces["ns2"]="http://www.apache.org/ode/pmapi/types/2006/08/02/"
def nodeCount = responseHolder.getDomNodes("//ns1:getCommunicationResponse[1]/getCommunicationResponse[1]/ns2:restoreInstance[1]/*").length
//log.info nodeCount

for (def nodeIndex = 1; nodeIndex <= nodeCount; nodeIndex++) {
def node = responseHolder.getDomNodes("//ns2:exchange[$nodeIndex]/ns2:operation[1]")
def node2 = responseHolder.getDomNodes("//ns2:exchange[$nodeIndex]/ns2:service")
node.each {
operations << it.firstChild.nodeValue ;
//log.info it.firstChild.nodeValue
}
node2.each {
services << it.firstChild.nodeValue ;
//log.info it.firstChild.nodeValue
}
}

new File('C:/Users/mahadevk/Downloads/jquery-ui-1.8.16.custom/myhtml.html').withWriter { file ->
new File('C:/Bskyb/HTML-learn/temp.html').eachLine { line ->
file.writeLine(line)
}
}
f = new File('C:/Users/mahadevk/Downloads/jquery-ui-1.8.16.custom/myhtml.html')
//g = new file('C:/Users/mahadevk/Downloads/jquery-ui-1.8.16.custom/new.html');

operations.eachWithIndex{ it, i ->
def j = i+1;
def request = responseHolder.getDomNodes("//ns2:exchange[$j]/ns2:in//*");
def op =it
def ser = services[i];
f.append("

$op : $ser

");
f.append("Request for the operation : $it" );
def Request= request.toString();
def prettyPrintRequest = xmlUtils.prettyPrintXml(Request);
f.append("Inside tab");
f.append("

");

f.append("");
f.append("

");
f.append("

");
f.append("

");

def response = responseHolder.getDomNodes("//ns2:exchange[$j]/(ns2:out|ns2:fault)//*");
f.append("Response for the operation : $it")
def Response= response.toString();
def prettyPrintResponse = xmlUtils.prettyPrintXml(Response);
//log.info prettyPrintResponse;
f.append("");
f.append("

");
f.append("
");
}
f.append("
");

No comments: