# Performing soap mtom  requests

**URL:** <https://community.gatling.io/t/performing-soap-mtom-requests/379>\
**Category:** Gatling (Open-Source)\
**Created:** [May 13, 2013, 1:25pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379 "2013-05-13T13:25:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 13, 2013, 1:25pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/1 "2013-05-13T13:25:33Z")

</div>

Hi,

We’re trying to create soap requests with attachments (mtom).

So far we’ve used fileBody(using ssp templates and placeholders for the xml-stuff), creating multipart boundaries etc manually.

Now, in our case the attachment is binary - this is giving us some problems due to non printable characters in pdf etc

What would be the best approach to solve this issue? Create a cusom fileBodyMtom thing?

Btw, we’re using gatling 1.5

Cheers,

Stefan

---

<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:** [May 13, 2013, 2:01pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/2 "2013-05-13T14:01:01Z")

</div>

I think we need a better multipart support.  
Let me think about it.

---

<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:** [May 14, 2013, 12:15am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/3 "2013-05-14T00:15:40Z")

</div>

Implemented in master: [https://github.com/excilys/gatling/issues/1163](https://github.com/excilys/gatling/issues/1163)

You’ll be able to grab a SNAPSHOT on Cloudbees in ~30 minutes: [http://repository-gatling.forge.cloudbees.com/snapshot/io/gatling/highcharts/gatling-charts-highcharts/2.0.0-SNAPSHOT/](http://repository-gatling.forge.cloudbees.com/snapshot/io/gatling/highcharts/gatling-charts-highcharts/2.0.0-SNAPSHOT/)  
Note that this won’t be backported as this part of the code is quite different, sorry.

Cheers,

Stéphane

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 7:59am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/4 "2013-05-14T07:59:27Z")

</div>

Man, you’re fast. Thanks for your great effort.

I’ve looked at your commit, andt seems the API lacks a feature that I would need in order to perform for instance SOAP MTOM requests

If you look at the example below (generated using apache cxf), you will notice that I need to be able to set several specific “http” headers per part. I can’t see how that can be achieved using the API you implemented.  
In addition, I need to be able to set a relatively complex content-type header (it’s a mulitpart related header ++) for the entire request, but I guess that should be ok?

POST /somewhere  
Other irrelevant headers…  
…  
…  
Content-Type: multipart/related; type=“application/xop+xml”; boundary=“uuid:BOUNDARY”; start=“[root.message@cxf.apache.org](mailto:root.message@cxf.apache.org)”; start-info=“text/xml”

–uuid:BOUNDARY  
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)\>

\<soapenv:Envelope xmlns:soapenv=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”\>  
soapenv:Body  
\<ns2:createDoc xmlns:ns2=“[http://some.namespace.com](http://some.namespace.com)” \>  
  
\<xop:Include xmlns:xop=“[http://www.w3.org/2004/08/xop/include](http://www.w3.org/2004/08/xop/include)” [href="cid:CID\_UID@cxf.apache.org](mailto:href=%22cid:CID_UID@cxf.apache.org)"/\>  
  
\</ns2:createDoc\>  
\</soapenv:Body\>  
\</soap:Envelope\>  
–uuid:BOUNDARY  
Content-Type: application/octet-stream  
Content-Transfer-Encoding: binary  
Content-ID: \<[CID\_UID@cxf.apache.org](mailto:CID_UID@cxf.apache.org)\>

PDF-BINARY-CONTENT  
–uuid:BOUNDARY

---

<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:** [May 14, 2013, 8:14am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/5 "2013-05-14T08:14:29Z")

</div>

Actually, Content-Type is the mimeType parameter, Content-Transfer-Encoding is automatically set when you send a File or a Byte array. The only thing that’s missing is this Content-ID custom header. AHC doesn’t currently support setting other headers.

Could you give it a try as is?  
If we really need those custom headers, I’ll have to hack AHC…

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 8:54am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/6 "2013-05-14T08:54:16Z")

</div>

I’m pretty sure we’ll need the Content-ID header - I’ll give it a shot anyways. I’ll keep you posted.

Kinda lame httpclient doesn’t support it. Seems like custom headers only can be applied to form-data mulitpart requests. I see no reason why.

---

<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:** [May 14, 2013, 8:59am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/7 "2013-05-14T08:59:52Z")

</div>

> I'm pretty sure we'll need the Content-ID header - I'll give it a shot  
> anyways. I'll keep you posted.

I'm quite pessimistic too...

> Kinda lame httpclient doesn't support it. Seems like custom headers only  
> can be applied to form-data mulitpart requests. I see no reason why.

Well, that's probably because you're the first one to ask for it 😉

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 10:51am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/8 "2013-05-14T10:51:01Z")

</div>

Ok. Just testet without the Content-ID header.

Cxf crashes: java.lang.IllegalStateException: No attachment for id [65ebb0c3-2116-4624-acef-572f848d458d@cxf.apache.org](mailto:65ebb0c3-2116-4624-acef-572f848d458d@cxf.apache.org) found in [root.message@cxf.apache.org]

It makes sense, since cxf otherwise won’t know which part to reference.

Also, the spec also has a nice example: [http://www.w3.org/Submission/soap11mtom10/](http://www.w3.org/Submission/soap11mtom10/)

Stefan

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 10:54am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/9 "2013-05-14T10:54:20Z")

</div>

How easy is it to get patches into ahc?

---

<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:** [May 14, 2013, 11:52am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/10 "2013-05-14T11:52:26Z")

</div>

What do you mean? How easy is it to develop Content-ID header support, or how easy is it to get a pull request accepted and a new release to be done?  
The former: simply adding Content-ID support is pretty straight forward, adding support for every kind of header is probably a bit more work. The main problem is compatibility.  
The latter: I’m an AHC committer, and Jean-François Arcand is a very nice guy and can do a release anytime.

I probably won’t have time to develop Content-ID before this week-end, probably beginning of next week. If you can help with a PR, that would be much appreciated. If you do so, beware of doing it against the 1.7.X branch, not master.

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 12:17pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/11 "2013-05-14T12:17:14Z")

</div>

ok. If you’re already an ahc committer it’s probibly way better that you implement this. I’ve hardly looked at the source of ahc since version 4.  
Cheers,

Stefan

---

<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:** [May 14, 2013, 12:20pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/12 "2013-05-14T12:20:28Z")

</div>

You’re confusing [apache httpclient](http://hc.apache.org) and [async http client](https://github.com/AsyncHttpClient/async-http-client). We use the latter.  
Being a committer doesn’t make me an expert, just someone willing to lend a hand. 😉

---

<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:** [May 14, 2013, 12:24pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/13 "2013-05-14T12:24:04Z")

</div>

Issue opened: [https://github.com/AsyncHttpClient/async-http-client/issues/296](https://github.com/AsyncHttpClient/async-http-client/issues/296)

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 14, 2013, 12:29pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/14 "2013-05-14T12:29:31Z")

</div>

I see, I see. Anyways, I looked at Apache Http Mime, and there is no support for adding custom headers (like Content-ID) there either. That might be an issue if you use apache as the backend for asynch client.

---

<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:** [May 14, 2013, 12:35pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/15 "2013-05-14T12:35:58Z")

</div>

AHC only supports Apache HttpClient v3 (pretty ugly story), which will be dropped in the next major release, and will never support v4.

Default Provider is Netty.

---

<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:** [May 14, 2013, 4:01pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/16 "2013-05-14T16:01:32Z")

</div>

I was able to quickly implement this: [https://github.com/excilys/gatling/issues/1166](https://github.com/excilys/gatling/issues/1166)

Could you give it a try, please?

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 15, 2013, 2:33pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/17 "2013-05-15T14:33:28Z")

</div>

Hi there,

I’m currently converting our project to 2.0 in order to test your fix, however, since I’m a total scala newbie, I’m struggeling with converting our custom functions.

We used to do stuff like this in 1.5

val injectSamlAssertion = (session: Session) =\> {  
val userid: String = session.getTypedAttribute(“userid”)  
session.setAttributes(Map(“userid” → userid, “saml” → saml.generateSingedAssertionForUser(userid)))  
}

scenario("whatever)  
.exec(injectSamlAssertion)

---

<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:** [May 15, 2013, 9:56pm UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/18 "2013-05-15T21:56:09Z")

</div>

- session(“foo”) returns an Any that can be casted with .asInstanceOf[String] into a String, but will crash if “foo” attribute is missing or if it’s not a String

- session.getString will return an Option[String], meaning that it will not crash is “foo” is missing, but will if it’s not a String

- session.getVString will never crash but you have to use it properly  
Your code is not very safe, but it will compile once to remove .success: there’s an implicit that does it for you, but you lack the import to do it explicitly.

The proper way is:

val injectSamlAssertion = (session: Session) =\> {  
session.getString.map(userid =\>  
session.setAll(Map(“userid” → userid, “saml” → saml.generateSingedAssertionForUser(userid))))  
}

---

<div class="post-metadata">

**Author:** ![Stefan\_Magnus\_Landro](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Stefan\_Magnus\_Landro](https://community.gatling.io/u/Stefan_Magnus_Landro)\
**Post date:** [May 16, 2013, 8:08am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/19 "2013-05-16T08:08:28Z")

</div>

Hi there,

I tried your code. It gives med the following error when I do exec(injectSamlAssertion):

scala: overloaded method value exec with alternatives:  
(scenario: io.gatling.core.structure.ScenarioBuilder)io.gatling.core.structure.ScenarioBuilder   
(chains: Iterable[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ScenarioBuilder   
(chains: Iterator[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ScenarioBuilder   
(chains: io.gatling.core.structure.ChainBuilder\*)io.gatling.core.structure.ScenarioBuilder   
(actionBuilder: io.gatling.core.action.builder.ActionBuilder)io.gatling.core.structure.ScenarioBuilder   
(sessionFunction: io.gatling.core.session.Session =\> io.gatling.core.validation.Validation[io.gatling.core.session.Session])io.gatling.core.structure.ScenarioBuilder  
cannot be applied to (io.gatling.core.Predef.Session =\> Option[io.gatling.core.session.Session])  
.exec(injectSamlAssertion)  
^

Just to clarify - what I’m trying to do is to exec() a function that will add a new attribute to the session (based on the userid session attribute) while keeping the existing ones.(similar to what is done here: [https://github.com/excilys/gatling/wiki/Inject-User-Specific-Data](https://github.com/excilys/gatling/wiki/Inject-User-Specific-Data)).

---

<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:** [May 16, 2013, 8:17am UTC](https://community.gatling.io/t/performing-soap-mtom-requests/379/20 "2013-05-16T08:17:28Z")

</div>

Could you send me your whole code so I can fix it at once, so we can avoid all the roundtrips?

[Next page](https://community.gatling.io/t/performing-soap-mtom-requests/379.md?page=2)
