Forum Discussion

Elsevier_-_OH_S's avatar
Elsevier_-_OH_S
Contributor
10 years ago

[Resolved] Event filter RequestFilter.afterRequest

I have a test suit where I need a soap request and a Rest request, problem occurred as we are changing response for REST services(because it has multiple Mime part , so we are getting the raw response and by combining all the parts into one and writing it back into the outline)before it gets into the Outline, but now I have soap cases into the same project, as we have this event RequestFilter.afterRequest set up at the project level I am not able to get soap response into the outline only coming in the raw response...below is the script.....please suggest if we can ignore soap request at this event and do it only for Rest ones., so that I can get all responses in the outline.

String rawResponseString = new String(context.httpResponse.getRawResponseData(), "UTF-8")

// Split it by "--simple_boundary".

def rawResponseList = rawResponseString.split("--simple_boundary")



def modifiedResponse = """
<responseHolder>
"""
if(rawResponseList.size() > 0){
rawResponseList = rawResponseList.tail();
}

//Looping all MIME part
for ( rawResponse in rawResponseList) {
//Check for the xml version tag end (?>)
if(rawResponse.indexOf("?>") > -1){
//Remove the string upto xml version
rawResponse = rawResponse.substring(rawResponse.indexOf("""?>""")+2)
}

if(rawResponse.indexOf("--") == 0){
rawResponse = "";
}
//adding all MIME parts in to the newly created xml response string
modifiedResponse += rawResponse;
}
//closing the newly created xml response string
modifiedResponse += """</responseHolder>""";


//assigning modified response into original response content
context.httpResponse.responseContent = modifiedResponse

11 Replies