Rob Bowman
Rob Bowman

Reputation: 8741

Send message of System.String is wrapping xml

I have a simple odx that constructs a message of type System.String, then pushes out through a send port.

The content of the output message is good except it's prefixed with:

<?xml version="1.0"?>
<string>

e.g.

<?xml version="1.0"?>
<string>
Good plain text format here

How can I prevent the content being wrapped with the without having to resort to a custom pipeline component?

Upvotes: 1

Views: 1989

Answers (2)

Dan Field
Dan Field

Reputation: 21661

Write the string directly to the XLANGMessage in a helper library (as if you were writing binary data to a message), and make sure to use a pass through transmit pipeline. I'm not sure if this would work with a System.String message or not, but I know it'd work with an XmlDocument message.

e.g.

public static void LoadXLANGMsgFromString(string source, XLANGMessage dest)
{
    var bytes = Encoding.UTF8.GetBytes(source);
    using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length, false, true))
    {
        dest[0].LoadFrom(ms);
    }
}

You need to use that constructor of MemoryStream to make sure the base data stream is exposed for XLANGs to make use of. Then, in an Orchestration message assignment shape:

msg = new System.Xml.XmlDocument();
Helper.LoadXLANGMsgFromString("Good plain text format here", msg);

Upvotes: 3

Vikas Bhardwaj
Vikas Bhardwaj

Reputation: 1510

Orchestration is expected to work with xml only typed or untyped. With string type, it automatically creates a xml wrapper over it. I think there will not be any way around it, unless you want to use a custom send pipeline component to take out the xml tag before writing.

Upvotes: 0

Related Questions