public async Task <DownloadLinkResult> getDownloadLinks(string updateIdentity, int revisionNumber, bool useMSAToken) { try { string request = buildDownloadLinkRequest(updateIdentity, revisionNumber, useMSAToken); string ret = await doHttpRequest(SECURED_URL, request); Xml.Save("Result.xml", ret); XDocument doc = XDocument.Parse(ret); var envelope = Xml.first_node_or_throw(doc.Root, NAMESPACE_SOAP + "Envelope"); var body = Xml.first_node_or_throw(envelope, NAMESPACE_SOAP + "Body"); var resp = Xml.first_node_or_throw(body, NAMESPACE_WU_SERVICE + "GetExtendedUpdateInfo2Response"); var res = Xml.first_node_or_throw(resp, NAMESPACE_WU_SERVICE + "GetExtendedUpdateInfo2Result"); var fileLocations = Xml.first_node_or_throw(res, NAMESPACE_WU_SERVICE + "FileLocations"); DownloadLinkResult data; data.files = new List <FileLocation>(); for (var it = Xml.first_node(fileLocations, NAMESPACE_WU_SERVICE + "FileLocation"); it != null; it = Xml.next_sibling(it, NAMESPACE_WU_SERVICE + "FileLocation")) { FileLocation info; info.url = Xml.first_node_or_throw(it, NAMESPACE_WU_SERVICE + "Url").Value; data.files.Add(info); } return(data); } catch (Exception ex) { throw new Exception("Failed to Find Download Links", ex); } }
public async Task <string> fetchConfigLastChanged() { string request = buildGetConfigRequest(); string ret = await doHttpRequest(PRIMARY_URL, request); XDocument doc = XDocument.Parse(ret); var envelope = Xml.first_node_or_throw(doc.Root, NAMESPACE_SOAP + "Envelope"); var body = Xml.first_node_or_throw(envelope, NAMESPACE_SOAP + "Body"); var resp = Xml.first_node_or_throw(body, NAMESPACE_WU_SERVICE + "GetConfigResponse"); var res = Xml.first_node_or_throw(resp, NAMESPACE_WU_SERVICE + "GetConfigResult"); return(Xml.first_node_or_throw(res, NAMESPACE_WU_SERVICE + "LastChange").Value); }
public async Task <CookieData> fetchCookie(string configLastChanged, bool useMSAToken) { string request = buildCookieRequest(configLastChanged, useMSAToken); string ret = await doHttpRequest(PRIMARY_URL, request); XDocument doc = XDocument.Parse(ret); var envelope = Xml.first_node_or_throw(doc.Root, NAMESPACE_SOAP + "Envelope"); var body = Xml.first_node_or_throw(envelope, NAMESPACE_SOAP + "Body"); var resp = Xml.first_node_or_throw(body, NAMESPACE_WU_SERVICE + "GetCookieResponse"); var res = Xml.first_node_or_throw(resp, NAMESPACE_WU_SERVICE + "GetCookieResult"); CookieData data; data.encryptedData = Xml.first_node_or_throw(res, NAMESPACE_WU_SERVICE + "EncryptedData").Value; data.expiration = Xml.first_node_or_throw(res, NAMESPACE_WU_SERVICE + "Expiration").Value; return(data); }
private void maybeThrowSOAPFault(XDocument doc) { string code = null; try { var envelope = Xml.first_node_or_throw(doc.Root, NAMESPACE_SOAP + "Envelope"); var body = Xml.first_node_or_throw(envelope, NAMESPACE_SOAP + "Body"); var fault = Xml.first_node_or_throw(body, NAMESPACE_SOAP + "Fault"); var detail = Xml.first_node_or_throw(fault, NAMESPACE_SOAP + "Detail"); var errorCode = Xml.first_node_or_throw(detail, "ErrorCode"); code = errorCode.Value; } catch (Exception) { } if (!string.IsNullOrEmpty(code)) { throw new SOAPError(code); } }
public async Task <SyncResult> syncVersion(CookieData cookie, bool useMSAToken) { string request = buildSyncRequest(cookie, useMSAToken); string ret = await doHttpRequest(PRIMARY_URL, request); XDocument doc = XDocument.Parse(ret); try { var envelope = Xml.first_node_or_throw(doc.Root, NAMESPACE_SOAP + "Envelope"); var body = Xml.first_node_or_throw(envelope, NAMESPACE_SOAP + "Body"); var resp = Xml.first_node_or_throw(body, NAMESPACE_WU_SERVICE + "SyncUpdatesResponse"); var res = Xml.first_node_or_throw(resp, NAMESPACE_WU_SERVICE + "SyncUpdatesResult"); var newUpdates = Xml.first_node_or_throw(res, NAMESPACE_WU_SERVICE + "NewUpdates"); SyncResult data = new SyncResult(); for (var it = Xml.first_node(newUpdates, NAMESPACE_WU_SERVICE + "UpdateInfo"); it != null; it = Xml.next_sibling(it, NAMESPACE_WU_SERVICE + "UpdateInfo")) { UpdateInfo info = new UpdateInfo(); info.serverId = Xml.first_node_or_throw(it, NAMESPACE_WU_SERVICE + "ID").Value; info.addXmlInfo(Xml.first_node_or_throw(it, NAMESPACE_WU_SERVICE + "Xml").Value); data.newUpdates.Add(info); } var newCookie = Xml.first_node(res, NAMESPACE_WU_SERVICE + "NewCookie"); if (newCookie != null) { data.newCookie.encryptedData = Xml.first_node_or_throw(newCookie, NAMESPACE_WU_SERVICE + "EncryptedData").Value; data.newCookie.expiration = Xml.first_node_or_throw(newCookie, NAMESPACE_WU_SERVICE + "Expiration").Value; } return(data); } catch (Exception e) { maybeThrowSOAPFault(doc); throw e; } }