-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MTOM attachments #43
Comments
Hi @jebbench, I've never used MTOM so I can't give you a good input right now, but from a fast analysis, it's seems to be tied to the communications protocol, not SOAP by itself, so I'm very reluctant to add support in the Let me dig deeper into this so I can give better input but if you need to support this fast, my best recommendation is to use the |
I've started having a play with this; you're right that it uses the http protocol to transmit the attachments rather than placing them in the SOAP envelope payload itself but I'd argue that the attachements are part of the SOAP message. https://www.w3.org/TR/soap12-mtom/ give a good overview of MTOM. I could use the I've currently dumped a bit of code into the middle of SoapClient to prove the mechanics; I'll tidy it up and move it to a handler if possible: var beforeHttpRequestHandlersResult =
await RunBeforeHttpRequestHandlers(
requestXml, url, action, trackingId,
beforeSoapEnvelopeSerializationHandlersResult.State, handlersOrderedAsc, ct);
var response =
await HttpClient.SendAsync(beforeHttpRequestHandlersResult.Request, ct).ConfigureAwait(false);
IDictionary<string, HttpContent> attachments = new Dictionary<string, HttpContent>();
if (response.Content.IsMimeMultipartContent())
{
var multipart = await response.Content.ReadAsMultipartAsync(ct);
foreach (var content in multipart.Contents)
{
if (content.Headers.ContentType.MediaType == "application/xop+xml")
{
// This is the SoapEnvelope
response.Content = content;
}
else
{
var cidMatch = _cidRegex.Match(content.Headers.GetValues("Content-Id").First());
if (cidMatch.Success)
{
attachments.Add(cidMatch.Groups[1].Value, content);
}
}
}
}
var handlersOrderedDesc = _handlers.OrderByDescending(e => e.Order).ToList();
var afterHttpResponseHandlersResult =
await RunAfterHttpResponseHandlers(
response, url, action, trackingId, beforeHttpRequestHandlersResult.State, handlersOrderedDesc, ct); |
I need support to receiving MTOM attachments from a service I'm calling; I'm going to look at submitting a PR for this.
Any advice on where to start implementing this? My current thinking is to add an
Attachments
property to theSoapEnvelope
and to intercept multipart responses inSoapClient.SendAsync
; extract the attachments and add them to the envelop and then continue processing the SOAP content as happens now.Cheers,
JB
The text was updated successfully, but these errors were encountered: