IdocProxy.SendIdoc(string idocData) call - doesnt this load the entire IDoc data in memory?

The SAP Adapter exposes a "generic" Send call which can be used to send any Idoc. In the Metadata SearchBrowse UI, this operation is visible as "SendIdoc" under the Idoc node.

The signature for this operation is

SendIdoc(string idocData, Guid guid)

The "guid" parameter is used if you want to use a TID when sending the Idoc to SAP (the adapter will map the guid to a TID). Assume that you dont want the guid. However, the idocData parameter is exposed as a string. This data is the flat-file idoc data. If you want to send a 100 mb idoc, and you use this proxy call, the entire 100mb data is going to get loaded into the string parameter. This is horrible!

Well, the way out would be to not use the proxy interface (the IdocProxy.SendIdoc() call), but instead program directly to the IOutputChannel or IRequestChannel interface, to send a WCF Message across to the adapter.

However, the way you create this Message can have an impact on the memory consumption. You can create a Message using a XmlReader, XmlDictionaryReader, or a BodyWriter. The adapter implementation is such that it consumes the Message using a XmlDictionaryWriter. Due to internal .NET implementation, if you create your message using a XmlReader or XmlDictionaryReader, and since the Adapter writes the message to a XmlDictionaryWriter, the entire idoc data will yet get loaded into memory (since the entire idoc data is present within a single Xml node). The way to get around this is for you to create your input message using a BodyWriter.

Attached is a sample which sends an idoc to the SAP Adapter by sending a WCF Message object, with this WCF Message object being created from the idoc data using a BodyWriter.