Search code examples
javascripthtmllyncucwa

How to send HTTPS get and set?


So I am currently in the process of learning how to use the Lync/Ucwa web API and struggling quite a bit. I am quite sure the first thing I need to do is contact the auto discovery service, below is the code on how you do it (I think).

/* Copyright (C) Microsoft 2013. All rights reserved. */
var domain = "https://www.example.com",
targetOrigin = "https://www.myDomain.com",
container = $("<div id='frameContainer'></div>"),
Transport = new microsoft.rtc.ucwa.samples.Transport(targetOrigin),

AutoDiscovery = microsoft.rtc.ucwa.samples.AutoDiscovery(Transport);
AutoDiscovery.startDiscovery(domain, container, handleResult);

function handleResult(data) {
    if (data !== null) {
        // Can start authentication
    } else {
        // Something went wrong as it was unable to find AutoDiscoverService root
    }
}

I was hoping someone could explain to me whats actually going on, when I contact the service with this, I guess by calling the script inside my html document, what am I going to get back and how on earth do I use it? I hope this makes sense, and that someone can help.

Thanks


Solution

  • If you have not downloaded the samples code you should look into that (UCWA SDK Samples) as it should provide smaller samples on how certain bits of functionality work like Presence, IM, Meetings, etc. The Lync Web Developer Portal's Code page has instructions on how to use the samples with credentials provided by the portal (you must sign in to get these credentials).

    If you are asking the more generic question of what each piece is doing, I would suggest looking at the following:

    The general idea of the JS samples is that an iframe will be injected into the page and the Transport component will use that iframe to issue cross-domain requests to the Lync Server. The response will come back as a JSON response which will be parsed out by however your applications needs to use that data.

    In the above example AutoDiscovery is setup to occur for http://www.example.com and a function called handleResult is setup as a callback to do something with the discovered root (or not). The UCWA Samples SDK also provides basics of how to do AutoDiscover/Authentication etc as you sign in to access the content. If you look into Index.js you can get an idea of how calls AutoDiscovery, Authenticates, and creates a UCWA application.