Forum Discussion
4 Replies
- Hello,
It's possible, but not documented. The Project should be a WsdlProjectPro (in soapUI PRO), which has an .addEventHandler(String type) method, which returns a DefaultSoapUIEventHandler. The DefaultSoapUIEventHandler has methods to set the properties available in the EventHandler editor: setName(String), setType(String), setTarget(String), setDisable(boolean) and getScript().setScriptText(String). The setType method sets the value in the Event column in the editor.
You can remove an EventHandler programatically by invoking .removeEventHandler(DefaultSoapUIEventHandler) on the WsdlProjectPro. Good luck!
An example:
def eventHandler = project.addEventHandler('RequestFilter.filterRequest')
eventHandler.name = 'MyEventHandler'
eventHandler.script.scriptText = """
log.info 'Hello from my handler!'
"""
Regards,
Dain
eviware.com - Holly_GregerContributorHi Dain,
Thank you, your response is helpful yet I find another road block. What about if i want to iterate through the list of existing event handlers? How could i check if an event handler is already present so i don't add a copy? Seems to me like the WsdlProjectPro documentation is not public, and for obvious resons but as a Pro user I need access to this information. Please provide me this much needed documentation.
Thank you
Enzo - Hello,
There a a few alternatives for getting the existing EventHandlers from the WsdlProjectPro. You can use the two methods getEventHandlerCount() and getEventHandlerAt( int index ) to iterate over the existing EventHandlers. You can also use getEventHandlers( String type ) to get an array of the EventHandlers of a specific type. As long as the EventHandlers have unique names, you can use getName() to check if an EventHandler is already present or not.
Regarding the Pro documentation, I've raised the question about making this available to our users.
Regards,
Dain
eviware.com - Holly_GregerContributorThank you Dain. I'll give those mehods a try, yet it'll be really helpful to have access to the Pro docs as it seems to be rich in functionality. Once again thanks, and I look forward to the documentation.