Forum Discussion
omatzura
17 years agoSuper Contributor
Hi Darren,
here comes the code for a DemoRequestFilter that removes all elements containing "--remove--" from the outgoing request:
Put this in the soapuipro\bin\scripts folder and add a demo-listeners.xml file in the soapuipro\bin\listeners folder containing:
The listener uses the standard regex-based String.replaceAll to remove these tags, you should be able to tweak it as required.
Regarding the SOAP-Fault, you could try using the same code as the NotSoapFaultAssertion:
ok.. hope I got all that right :-)
regards!
/Ole
eviware.com
here comes the code for a DemoRequestFilter that removes all elements containing "--remove--" from the outgoing request:
package soapui.demo
import com.eviware.soapui.SoapUI
import com.eviware.soapui.impl.wsdl.submit.transports.http.BaseHttpRequestTransport
import com.eviware.soapui.impl.wsdl.submit.RequestFilter
import com.eviware.soapui.impl.wsdl.WsdlRequest
import com.eviware.soapui.model.iface.Response
import com.eviware.soapui.model.iface.SubmitContext
public class DemoRequestFilter implements RequestFilter
{
public void afterRequest( SubmitContext context, Response response )
{}
public void filterRequest( SubmitContext context, WsdlRequest wsdlRequest )
{
String content = (String) context.getProperty( BaseHttpRequestTransport.REQUEST_CONTENT )
if( content == null )
{
System.err.println( "Missing request content in context, skipping demofilter" )
}
else
{
System.out.println( "running demofilter" )
content = content.replaceAll( "<(.+)>--remove--</(\\1)>", "" )
context.setProperty( BaseHttpRequestTransport.REQUEST_CONTENT, content )
}
}
}
Put this in the soapuipro\bin\scripts folder and add a demo-listeners.xml file in the soapuipro\bin\listeners folder containing:
<?xml version="1.0" encoding="UTF-8"?>
<tns:soapui-listeners xmlns:tns="http://eviware.com/soapui/config">
<tns:listener id="DemoListener" listenerClass="soapui.demo.DemoListener"
listenerInterface="com.eviware.soapui.model.testsuite.TestRunListener" />
</tns:soapui-listeners>
The listener uses the standard regex-based String.replaceAll to remove these tags, you should be able to tweak it as required.
Regarding the SOAP-Fault, you could try using the same code as the NotSoapFaultAssertion:
def responseContent = messageExchange.responseContent
def soapVersion = messageExchange.operation.getInterface().soapVersion
assert !com.eviware.soapui.impl.wsdl.support.soap.SoapUtils.isSoapFault( responseContent, soapVersion )
ok.. hope I got all that right :-)
regards!
/Ole
eviware.com
Related Content
- 6 years ago
- 10 years ago
Recent Discussions
- 18 hours ago
- 17 days ago