# SOAP, XPath and multipart response

**URL:** <https://community.gatling.io/t/soap-xpath-and-multipart-response/1740>\
**Category:** Gatling (Open-Source)\
**Created:** [November 25, 2014, 9:31am UTC](https://community.gatling.io/t/soap-xpath-and-multipart-response/1740 "2014-11-25T09:31:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simon\_Manquest](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Simon\_Manquest](https://community.gatling.io/u/Simon_Manquest)\
**Post date:** [November 25, 2014, 9:31am UTC](https://community.gatling.io/t/soap-xpath-and-multipart-response/1740/1 "2014-11-25T09:31:26Z")

</div>

Hello,

First of all, great work with Gatling, I’m really loving it !

I’ve got some trouble consuming a SOAP WebService.

The request is fine, but the response looks like that :

HTTP response:  
status=  
200 OK  
headers=  
Server: [Apache-Coyote/1.1]  
Content-Type: [multipart/related; type=“application/xop+xml”; boundary=“uuid:102b75da-ad3f-4b96-938a-d13a2f4feeda”; start=“[root.message@cxf.apache.org](mailto:root.message@cxf.apache.org)”; start-info=“text/xml”]  
Transfer-Encoding: [chunked]

body=  
–uuid:102b75da-ad3f-4b96-938a-d13a2f4feeda  
Content-Type: application/xop+xml; charset=UTF-8; type=“text/xml”  
Content-Transfer-Encoding: binary  
Content-ID: [root.message@cxf.apache.org](mailto:root.message@cxf.apache.org)

–uuid:102b75da-ad3f-4b96-938a-d13a2f4feeda–

The gatling error is _Could not parse response into a DOM Document: org.xml.sax.SA…_  
I assume it’s the first part (uuid, Content-Type…) which prevents the parser to do its job, but I can’t get how to just extract the SOAP xml part so I can use my XPath expression. I found some information with SOAP/MTOM requests, but I didn’t find anything on parsing the response.

Could you provide some help please ?

Simon

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [November 25, 2014, 9:52am UTC](https://community.gatling.io/t/soap-xpath-and-multipart-response/1740/2 "2014-11-25T09:52:48Z")

</div>

You won’t be able to use XPath on the response body as it’s not valid XML. The reason is that it’s not a plain body, but a multipart one.  
Sadly, Gatling doesn’t have any built-in feature for dealing with multipart responses at the moment.

What you could do is parse the [bodyBytes](http://gatling.io/docs/2.0.3/http/http_check.html?highlight=bodybytes#http-response-body) inside a [transform](http://gatling.io/docs/2.0.3/http/http_check.html?highlight=bodybytes#transforming) step with [javamail](https://docs.oracle.com/javaee/5/api/javax/mail/internet/MimeMultipart.html) so you can grab the parts you’re interested in and extract what you exactly want with either Saxon or Xalan.

Cheers,

Stéphane

---

<div class="post-metadata">

**Author:** ![Simon\_Manquest](https://avatars.discourse-cdn.com/v4/letter/s/bc79bd/32.png) [@Simon\_Manquest](https://community.gatling.io/u/Simon_Manquest)\
**Post date:** [November 25, 2014, 9:58am UTC](https://community.gatling.io/t/soap-xpath-and-multipart-response/1740/3 "2014-11-25T09:58:28Z")

</div>

Thank you for you answer Stéphane.  
We are currently using regex to parse the body as a workaround. I guess we’ll have to continue until the multipart responses are handled by Gatling 🙂

Have a nice day,  
Simon
