Re: [gmime-devel] Using GMime to build SOAP multipart messages



Hi Johan,

On 7/14/2014 7:37 AM, Johan van den Berg wrote:
Hi

Hopefully this turns out to be really simple and I'm staring at the obvious but not connecting the dots. :)

I have two problems:

1:
I want to construct MIME multipart/related messages for use with SOAP as such: http://www.w3.org/TR/SOAP-attachments

Essentially, its a multipart/related where its first part is a SOAP envelope XML string, followed by attachment parts or even other embedded multiparts.

Building this multipart I think I have figured out. The problem I am running into is that I need to separate the top level multipart message's headers from the rest of its contents, as I need to set these headers as HTTP headers. (I am using libcurl to facilitate the HTTP part of the process).

I COULD go and do this by simply calling g_mime_object_to_string() on the GMimeObject and searching for the start of the boundary (from the Content-Type header), and only copying the rest for use as the body. But I was hoping that there would be a neater way to do this directly.

Unfortunately, that's the the only way to do it I think.



2:
I already have my attachments as base64 encoded strings when I get to this point in the process. I would like to add them as parts to the multipart directly (with Content-Transfer-Encoding set to base64), without needing to decode and re-encode the data unnecessarily.

This one is easy :-)

When you create the GMimeDataWrapper, instead of specifying the encoding as GMIME_CONTENT_ENCODING_DEFAULT, use GMIME_CONTENT_ENCODING_BASE64.

This tells the GMimePart that contains the GMimeDataWrapper as its content that the content is already base64 encoded.

Hope that helps,

Jeff

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]