An interesting thing happened on this project the other day, I wanted to call a WebSite (i.e. do a HTTP GET, then grab the HTML Response) just to make sure that it’s up and running.

It wasnt a webservice call, just a standard HTTP GET and HTML is returned (bit like
going to the Cricket sites, to see the current scores! 🙂

I created an Orchestration with a
msgResponse = Microsoft.XLANGs.BaseTypes.Any (this was coming back from the
WebSite call)

I then sent it straight back to the caller – using PassThru pipelines where ever needed,
as this message had HTML and not XML, so no XML inspection could be done.

As the goal posts moved, I then needed to Inspect the HTML Response for a certain
Version value within the HTML Response.
I thought “How do I do anything with a Message type of ‘Any’?

1. Could I just send it back out to disk, a folder…when I open the resulting file
it appears all there.
2. Transform it into something more meaningful??
3. Send it to a helper class for further processing?

My problem was that the response was a HTML message and not a XHTML Response.

I even threw in a helper method from within an expression type to try and get the
type.
e.g. EventLog.WriteEntry(“I got ” + Type.GetType(msgResponse))

One of the problems I had was that I couldnt declare a helper method of
public static string GetMessageAsString(Microsoft.XLangs.Any msg) {…..}


The compiler jumps up and down and does nasty things to you!

What is the type of ‘Any’ in C# is the 64 million dollar question.

We know that all common Orchestrations Messages can be passed through as an XLANGMessage with
it’s parts + properties. All good.
(I tried this, it failed miserably)

After sheer determination and having an overloaded helper method with 10 different
possible types (I was racking my brain from XLANGMessage, to BTXMessage, to Object….etc) the
type that relates the ‘ANY’ element is XLANGPart
as follows:

    public static string RetrieveMessageAsString(XLANGPart pt)
        {
            StreamReader rdr = new StreamReader((Stream)pt.RetrieveAs(typeof(Stream)));
            string s = rdr.ReadToEnd();
            return(s);
        }


NOTE: This doesnt deal with different byte encodings, but is easy enough to implement.