I’m currently struggling to make some checks/validations on multipart responses.
My response consists of two parts, the SOAP response and some binary data (MTOM response).
I.e. the body looks like this:
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
// my binary data
The header of the response message has the following
Content-Type: multipart/related; type="application/xop+xml";
When I use the
bodyString() method, I get only the content of the first part (i.e. the SOAP-Message content starting with
bodyLength() method also takes only the content of the first part into consideration.
xpath() check on the other hand seems tries to use the whole response and fails, as it is no valid xml.
transformResponse(...) method, the
response.body contains the whole body starting with
Is there any other way than the
transformResponse() to access the second part of the multi-part response and perform some checks on that part?
No, we don’t have any built-in support for multipart responses, so you indeed have to parse the response bytes yourself.
bodyBytes() returns only the bytes of the first multipart message, i.e. only the SOAP message like
regex(..) receives only the body of the first part.
The only way I found so far to access the whole message is using the
bodyBytes() returns only the bytes of the first multipart message
This is not correct (or it’s a bug, but I doubt that).
bodyBytes() returns the bytes of the full HTTP response body.
bodyString() returns also the full response body, but decoded as chars (with the charset being either from the
content-type header or by default, the one defined in Gatling’s conf), which is most likely a mess in your case as your response body is not text.
Is it possible that the order of
transformResponse() is not maintained and
transformResponse()is always executed first?
So if I have something like this (Java):
http("my http request")
.header(HttpHeaderNames.CONTENT_TYPE, "multipart/related; type=\"application/xop+xml\"")
I would expect that the order of execution is
I.e. the first
bodyLength() check returns the length of the whole body, then the body gets reduced, and finally the second check returns the length of the transformed body.
However, it seems that
transformResponse is executed first, as both
bodyLength() calls returns the same result.
transformResponse is applied to the response prior to any check. The order you define checks doesn’t matter.
Thanks, that explains my problems…
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.