maximum mime part of a document cannot exceed 64K...
- hello all:
we were looking at the wwsapi for one of our projects to interact with a jax-ws from our native code. we have a need where in large blobs of data needs to be sent from the client to the jax-ws. we couldn't use streaming, as this doesn't seem to be supported on w2k3 (and it is a requirement for our product to be run on this platform). thus, we were looking to see if we may use mtom to send this information over to the other end. MTOM seems to be supported, but oddly enough does *not * let the MIME part of a single
message to be >64KB. this happens when i invoke the stub method generated by the wsutil compiler.
the error we seem to be getting is:
The maximum size of the MIME parts for the document (65536 (0x10000)) was exceeded by (356351 (0x56FFF)) bytes.
I have struggled with this to see if I can somehow reach under the hoods to grab the XML writer that is involved in this and to see if its properties could be set to overcome this limitation. however, my efforts have been futile thus far.
i'm assuming that the following property is what needs to be defined on the underlying XML writer to change this. I could enable this and push an XML message that is MTOM encoded into this. however, there doesn’t seem to be an API to write this (content from the XML writer) to the underlying channel// This is the maximum that a single mime part can buffer when
// mtom encoding is enabled.
// WS_XML_WRITER_PROPERTY_MAX_MIME_PARTS_BUFFER_SIZE
// WS_XML_WRITER_PROPERTY_ID
basically, i did the following:
1. create an xml writer with the above prop-set (defined with a value > 64K)
2. create a channel (with its properties) and opened it
3. created a message for this channel
4. initialized the message
5. created an WS_XML_WRITER_BUFFER_OUTPUT with o/p type WS_XML_WRITER_OUTPUT_TYPE_BUFFER
6. created WS_XML_WRITER_MTOM_ENCODING with encoding type WS_XML_WRITER_ENCODING_TYPE_MTOM
7. set o/p to the xml writer to #6
8. associate the writer to the message via WsWriteEnvelopeStart
9. invoke writebody to write the contents
10. tried to send message via sendmessage, writeenvelopeend etc. to no avail
questions:
1. how do we increase this default size of 64K such that we can push more than that in a mime encoded message via mtom
2. is that the right property we should be tweaking
3. how do we send the message when we have buffered all the content that needs to be written to the channel inside the xml writer?
4. is there a way to change this propery *and* still use the stub method generated by the wsutil compiler
5. any examples that demonstrates this (i have looked at a few - messageencoding, readwitexml, httprawservice, httpgetservice etc.; but they do not seem to be demonstrating this)
thanks in advance for everyones time.
Answers
Hi,
You need to set the XmlWriter Property of the message that you send across. This can be done by setting the property WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES. And then through the CreateMessageForChannel API you would set these properties for the message.
static ULONG streamSize = 1 << 24;
static WS_XML_WRITER_PROPERTY writerProperty[1] =
{
{WS_XML_WRITER_PROPERTY_MAX_MIME_PARTS_BUFFER_SIZE, &streamSize, sizeof(streamSize)}
};
static WS_XML_WRITER_PROPERTIES writerProperties = {writerProperty, 1};
static WS_MESSAGE_PROPERTY messageProperty[1] =
{
{WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES, &writerProperties, sizeof(writerProperties)},
};
static WS_MESSAGE_PROPERTIES messageProperties = {messageProperty, 1};
WsCreateMessageForChannel(
relatedChannel, //Channel * channel
messageProperties.properties, //const WS_MESSAGE_PROPERTY * properties
messageProperties.propertyCount, //ULONG propertyCount
&_message, //Message * * outMessage
error //Error * error
),error);
WsSendMessage should work on the client side to send the actual message across. The encoding should be set on the channel layer - WS_ENCODING_XML_MTOM_UTF8/16LE/BE depending on what the service is using.
Try this out and see if this works for you.- Marked As Answer byNikola Dudar [MSFT]MSFTThursday, August 20, 2009 5:20 PM
All Replies
Hi,
You need to set the XmlWriter Property of the message that you send across. This can be done by setting the property WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES. And then through the CreateMessageForChannel API you would set these properties for the message.
static ULONG streamSize = 1 << 24;
static WS_XML_WRITER_PROPERTY writerProperty[1] =
{
{WS_XML_WRITER_PROPERTY_MAX_MIME_PARTS_BUFFER_SIZE, &streamSize, sizeof(streamSize)}
};
static WS_XML_WRITER_PROPERTIES writerProperties = {writerProperty, 1};
static WS_MESSAGE_PROPERTY messageProperty[1] =
{
{WS_MESSAGE_PROPERTY_XML_WRITER_PROPERTIES, &writerProperties, sizeof(writerProperties)},
};
static WS_MESSAGE_PROPERTIES messageProperties = {messageProperty, 1};
WsCreateMessageForChannel(
relatedChannel, //Channel * channel
messageProperties.properties, //const WS_MESSAGE_PROPERTY * properties
messageProperties.propertyCount, //ULONG propertyCount
&_message, //Message * * outMessage
error //Error * error
),error);
WsSendMessage should work on the client side to send the actual message across. The encoding should be set on the channel layer - WS_ENCODING_XML_MTOM_UTF8/16LE/BE depending on what the service is using.
Try this out and see if this works for you.- Marked As Answer byNikola Dudar [MSFT]MSFTThursday, August 20, 2009 5:20 PM

