November 2, 2017 at 8:03 am #8823Aditya PhatakParticipant
While testing a service which uses a message and its sub-parts, we found that the end system has restricted size of the message to 65kb.
I wanted to check the size of the message which is formed using the given XSD, but there was no such function available.
Is there a way to convert the message object to a string so that we can evaluate its size using (string-length xmlMessage)?
Is there a way to directly evaluate size of a message object in scheme console?0
November 4, 2017 at 10:43 am #8831Ed ShawKeymaster
There is definitely a way to check how large a message will be “on the wire” before sending it. I’m assuming that you have an integration Service that populates a Message which has an XML Format. If you send the message over an HTTP channel, the message will be automatically formatted for you from it’s internal representation (Transfer Object) to its external representation (in this case an XML string, but this would work the same if it was JSON formatted or any of the other supported formats).
So what we need to do is format our message to XML *before* sending it so we can check it’s size. To do this, simply do the following.Scheme1((format-message myMessage)'length)
Test this value against your upper limit and do some error handling or message chunking as appropriate.
Just as a reminder, you have two options for sending messages over HTTP (and other) channels. The first is to just send the message over the channel and let the message get formatted automatically *or* you may format the message yourself and put the resulting text in the body part of an HTTP message. This gives you a bit more dynamic control over the headers, … of the message.
e.g.Scheme12345678(message(: :class "HTTP")(: headers(message (: content-type "text/xml")))(: url "http://someserver.a.com")(: body (format-message myMessage)))0
- You must be logged in to reply to this topic.