Hoobajoob
11 years agoOccasional Contributor
Extract substring from response body
I think this may be an xpath question, not sure.
I have a test case that exercises a REST method and the result returns a raw url in the message body, no xml or json. I believe it returns this same value in the HTTP location header. The url includes an id field, and I want to save just that id value and transfer it to a test case property. The length of the id field is variable (I can't count on it always being so many characters long).
Response body looks like:
http://<server>:<port>/objects/{id}
...where <server> and <port> are property values from an earlier data source step, and {id} is generated by the service, and has a different value after each request.
I have a property transfer step after the REST method, but I can't find anything obvious for doing this simple substring operation: give me everything after the last occurrence of '/' in the response body. I was hoping for regular expressions and capture groups, but I don't see any support for this kind of thing in SoapUI.
Does anybody know how to do this? Treat the response as xml and try using xpath to get this substring? I'm not an xpath expert, but I don't remember xpath being much use for substring operations like this where you don't know what the length of the string is, or the values of <server> and <port> at design time.
I have a test case that exercises a REST method and the result returns a raw url in the message body, no xml or json. I believe it returns this same value in the HTTP location header. The url includes an id field, and I want to save just that id value and transfer it to a test case property. The length of the id field is variable (I can't count on it always being so many characters long).
Response body looks like:
http://<server>:<port>/objects/{id}
...where <server> and <port> are property values from an earlier data source step, and {id} is generated by the service, and has a different value after each request.
I have a property transfer step after the REST method, but I can't find anything obvious for doing this simple substring operation: give me everything after the last occurrence of '/' in the response body. I was hoping for regular expressions and capture groups, but I don't see any support for this kind of thing in SoapUI.
Does anybody know how to do this? Treat the response as xml and try using xpath to get this substring? I'm not an xpath expert, but I don't remember xpath being much use for substring operations like this where you don't know what the length of the string is, or the values of <server> and <port> at design time.