Dela via


Sending a Message by Posting an XML Element

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

When the posting URL is retrieved, a client application can send all other requests to the conference center by sending the corresponding request elements using an HTTPS POST.

Code Example

The following example uses HttpWebRequest and HttpWebResponse classes supported by the Microsoft .NET Framework.

public XmlDocument PostXmlMessageRequest(XmlDocument xmldoc)
{
    // Upon entering, xmldoc = messageRequest
    // Upon exit, xmlReply = messageReply;

    ASCIIEncoding encoder = new ASCIIEncoding();
    XmlDocument xmlReply = null ;

    // Post the <messageRequest> element to the conference center;
    HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(postingUrl);
    myReq.Method = "POST";
    myReq.ContentType = "application/x-www-form-urlencoded";

    HttpWebResponse myResp = null;
    try
    {
        // Write the XML message to the request stream and
        // send it to the conference center
        byte[] byteArray = encoder.GetBytes(xmldoc.OuterXml);
        myReq.ContentLength = byteArray.Length;
        Stream reqStream = myReq.GetRequestStream();
        reqStream.Write(byteArray, 0, byteArray.Length);
        reqStream.Close();

        // Get the response from the conference center
        myResp = (HttpWebResponse)myReq.GetResponse();
        Stream respStream = myResp.GetResponseStream();
        if (myResp.ContentType == "application/xml")
        {
            xmlReply = new XmlDocument();
            xmlReply.Load(respStream);
        }
    }
    catch (Exception e)
    {
        // Log the error or implement other error handling routines
        Console.WriteLine("Error: {0}\nStack trace: {1}",
                            e.Message, e.StackTrace);
    }
    finally
    {
        if (myResp != null)
            myResp.Close();
    }

    return xmlReply;
}

VBScript Code Example

set xmlpost = createobject("WinHttp.WinHttpRequest.5.1")
xmlpost.Open "POST", postingUrl, "false"
xmlpost.send(xmldoc)
wscript.echo xmlpost.responseXML.xml & vbcrlf

See Also

Concepts

Using the Live Meeting service API