hbjastad
10 years agoContributor
Turning off "Accept compressed responses from host" programmatically
Hi, I am trying to write an integration test in Java using SoapUI and the following code is able to do that:
// create new project
WsdlProject project = new WsdlProject();
// import WSDL
WsdlInterface wsdl = WsdlInterfaceFactory.importWsdl(project, endpoint.getWsdlUrl(), true)[0];
// get desired operation
WsdlOperation operation = wsdl.getOperationByName(operationName);
// create a new empty request for that operation
WsdlRequest request = operation.addNewRequest("My request");
//WsdlRequest request = operation.getRequestAt(0);
request.setEndpoint(endpoint.getEndpoint());
// generate the request content from the schema
request.setRequestContent(operation.createRequest(true));
// submit the request
WsdlSubmitContext submitContext = new WsdlSubmitContext(request);
WsdlSubmit submit = request.submit(submitContext, false);
// wait for the response
Response response = submit.getResponse();
// validate the response
String content = response.getContentAsString();
System.out.println(content);
But when I look at the content, it is scrambled. The following 2 posts suggests that the solution is to turn off "Accept compressed responses from host":
But I need to do this programmatically, not from the UI. How can I achieve the same programmatically?
Any way here it is to change the settings
//Change value what is needed for you true or false boolean value = false; SoapUI.getSettings().setBoolean(HttpSettings.RESPONSE_COMPRESSION, value);