Ask a Question

Listeners - Modifying Requests before posting to a Service

cdunne
Contributor

Listeners - Modifying Requests before posting to a Service

Hi,

We have a large number of optional elements in our Service requests. One of the issues I am coming accross regularly is a number of them cannot be passed as empty tags due to the type declaration.

We have build a framework driven from excel datasheets but we don't want to have to build large numbers of template requests based on different business rules.

Is there a way of only stripping the empty optional elements before a request is sent to the service? Does SoapUI Pro have this functionality or do I need to script something to handle it?

One way I thought would be to have a listener that calls a script to remove any empty elements from the request by default unless specified in the datasheet. Is this possible? I can't find any examples of using a listener on a particular test step or any examples of where I would start.

Thanks

Darren
16 REPLIES 16
omatzura
Super Contributor

Hi Darren,

ok.. could we do a webex session so I can have a closer look at your setup/configuration to see what is happening? If so, please mail me at ole@eviware.com and I'll invite..

Sorry for the inconvenience..

regards!

/Ole
eviware.com
cdunne
Contributor

Hi Ole,

I had an older version of SoapUI Pro on the machine which I removed, plus I removed all my scripts. I now get teh following error at startup.

09:05:36,752 INFO  [DefaultSoapUICore] Adding listeners from [C:\Program Files\e
viware\soapUI-Pro-2.0.3\bin\listeners\demo-listeners.xml]
Error initializing Listener: java.lang.RuntimeException: Listener class: soapui.
demo.DemoListener must implement interface: com.eviware.soapui.model.testsuite.T
estRunListener

Makes a bit more sense now.
Cheers

Darren
omatzura
Super Contributor

Hi Darren,

duh.. the fault is mine.. the config should be



   
listenerInterface="com.eviware.soapui.impl.wsdl.submit.RequestFilter" />


works better?

regards,

/Ole
eviware.com
cdunne
Contributor

Hi Ole,

Thanks for that, it now appears to be running the filter. Any way of checking if the correct request is being sent?

I've tried adding

SoapUI.log.info("request sent:   "+context.getProperty( BaseHttpRequestTransport.REQUEST_CONTENT ))

after the new message is set but that prints the request unmodified. Is this correct, if so then I must have a problem with the filter?

Cheers

Darren
omatzura
Super Contributor

Hi Darren,

hmm again 🙂 In what does this not work? Gives an error? Shows the wrong request? etc..

regards!

/Ole
eviware.com
cdunne
Contributor

Hi Ole,

Oh yeah sorry if I add --empty-- in an element I would expect that element to be stripped out of the request. For example,


 

 
     
       
            MDUserDescTyMeteor
            MDAppDescTyWeb
            MDAppIDTyMDS

            --empty--
       

        --empty--
     

 



I would expect the following request to be sent,


 

 
     
       
            MDUserDescTyMeteor
            MDAppDescTyWeb
            MDAppIDTyMDS

       

     

 


If I add that extra line in the filter, after the setProperty call, 
SoapUI.log.info("request sent:  "+context.getProperty( BaseHttpRequestTransport.REQUEST_CONTENT ))

I would expect the updated request to be printed to the log?

Cheers

Darren
omatzura
Super Contributor

Hi Darren,

unless you've changed the code, it should be "--remove--", not "--empty--". Is that it?

regards!

/Ole
eviware.com
cancel
Showing results for 
Search instead for 
Did you mean: