Forum Discussion

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

soapui script works at test step level and failed at test su

soapui script works at test step level and failed at test suit or test case level or Project level for event "RequestFilter.afterRequest"
if( request.response == null )
return

// get response content
def content = context.httpResponse.responseContent
//log.info content

def sub1 = content.substring(0, content.indexOf("<ns2:IDs>"))
//log.info "sub1: " + sub1
def sub2 = content.substring(content.indexOf("</ns2:IDs>")+10)
//log.info "sub2: " + sub2
content = sub1 + sub2
//log.info content

// write it back
context.httpResponse.responseContent = content

4 Replies

  • Hi,

    Please explain the error you are getting (including the stack trace) and the problem you are trying to solve.



    Regards,
    Marcus
    SmartBear Support
  • Below is the Stated Problem...i was using the script posted in the previous post for doing this but this script works at test step level and failed at test suit or test case level or Project level for event "RequestFilter.afterRequest"

    ((if( request.response == null )
    return

    // get response content
    def content = context.httpResponse.responseContent
    //log.info content

    def sub1 = content.substring(0, content.indexOf("<ns2:IDs>"))
    //log.info "sub1: " + sub1
    def sub2 = content.substring(content.indexOf("</ns2:IDs>")+10)
    //log.info "sub2: " + sub2
    content = sub1 + sub2
    //log.info content

    // write it back
    context.httpResponse.responseContent = content
    )))
    Hi I am trying to put check point using For Content assertion For my whole response posted below.....<ns2:d>5</ns2:d>
    <ns2:me>DSc</ns2:me>
    <ns2:tN>7</ns2:tN=>
    <ns2:su>
    <ns2:I>7</ns2:I>
    <ns2:m>A</ns2:m>
    <ns2:r>7</ns2:r>
    </ns2:su>
    <ns2:pl>p</ns2:l>
    <ns2:dg>N</ns2:dg>
    <ns2:ds>B</ns2:ds>
    <ns2:s>ne</ns2:s>
    <ns2:p>CE</ns2:p>
    <ns2:y>AL</ns2:y>
    <ns2:t>true</ns2:t>
    <ns2:d>false</ns2:d>
    <ns2:l>nobody.com</ns2:l>
    <ns2:o>(12943071)</ns2:o>
    <ns2:b>false</ns2:b>
    <ns2:s>C99</ns2:s>
    <ns2:e>en</ns2:e>

    <ns2:A>
    <ns2:All>34</ns2:ALL>
    <ns2:st>C291210</ns2:st>
    <ns2:Date>25-Mar-2014 08:01:32</ns2:Date>
    <ns2:ehr>true</ns2:ehr>
    </ns2:Info>
    <ns2:IDs>
    <ns2:id>1</ns2:id>
    <ns2:id>4</ns2:id>
    <ns2:id>5</ns2:id>
    <ns2:id>6</ns2:id>
    <ns2:id>0</ns2:id>
    <ns2:id>2</ns2:id>
    <ns2:id>3</ns2:id>
    <ns2:id>5</ns2:id>
    <ns2:id>9</ns2:id>
    <ns2:id>0</ns2:id>
    <ns2:id>3</ns2:id>
    <ns2:id>8</ns2:id>
    <ns2:id>9</ns2:id>
    <ns2:id>5</ns2:id>
    <ns2:id>10</ns2:id>
    <ns2:id>22</ns2:id>
    <ns2:id>23</ns2:id>
    <ns2:id>26</ns2:id>
    <ns2:id>27</ns2:id>
    <ns2:id>28</ns2:id>
    <ns2:id>33</ns2:id>
    <ns2:id>38</ns2:id>
    <ns2:id>39</ns2:id>
    <ns2:id>43</ns2:id>
    <ns2:id>44</ns2:id>
    <ns2:id>50</ns2:id>
    <ns2:id>51</ns2:id>
    <ns2:id>67</ns2:id>
    <ns2:id>367</ns2:id>
    <ns2:id>69</ns2:id>
    <ns2:id>70</ns2:id>
    <ns2:id>83</ns2:id>
    <ns2:id>15</ns2:id>
    <ns2:id>5</ns2:id>
    <ns2:id>20</ns2:id>
    <ns2:id>71</ns2:id>
    <ns2:id>21</ns2:id>
    <ns2:id>92</ns2:id>
    <ns2:id>67</ns2:id>
    <ns2:id>69</ns2:id>
    <ns2:id>65</ns2:id>
    <ns2:id>67</ns2:id>
    <ns2:id>70</ns2:id>
    <ns2:id>74</ns2:id>
    <ns2:id>95</ns2:id>
    <ns2:id>73</ns2:id>
    </ns2:IDs>
    <ns2:wedReg>NONE</ns2:wedReg>
    <ns2:s>53I1T2WvEy25jjPdnj5xaCgRGGYltmlCqr3q7rjHf9y</ns2:s>
    </ns2:Info>
    <ns2:A>

    MY problem is i want to Remove below all IDs tag becaue it is very dynamic, some time these tags increase and decreases and va;ues change accordingly. I want to keep all other tags above in the response. Is there any way i can assert full response removing only this tag.
  • Hi,

    I believe my colleague Giscard is handling this on separate tickets you submitted. The "RequestFilter.afterRequest" event handler does work on a test case, test suite, and project level if you are using a web service deployed to a actual server (such as tomcat). Are you using a mock service or an actual service on a application server?


    Regards,
    Marcus
    SmartBear Support
  • Hi,

    After some investigation I found out you need to comment out this line in the script for it to run correctly at all levels other than test step such as testsuite, test case, etc.

    Replace

    if( request.response == null )
    return


    with

    /*
    if( request.response == null )
    return
    */



    Regards,
    Marcus
    SmartBear Support