public Response Execute(ActiveSync.RequestBase request) { string url = string.Format(ACTIVESYNC_URL, _account.Account.ServerURL, Uri.EscapeDataString(_account.Account.DeviceId), request.Command, Uri.EscapeDataString(_account.Account.UserName), "WindowsOutlook"); // Construct the body WBXMLDocument doc = new WBXMLDocument(); doc.LoadXml(request.Body); doc.VersionNumber = 1.3; doc.TagCodeSpace = new ActiveSyncCodeSpace(); doc.Encoding = Encoding.UTF8; byte[] contentBody = doc.GetBytes(); using (HttpContent content = new ByteArrayContent(contentBody)) { Logger.Instance.Trace(this, "Sending request: {0} -> {1}", _account.Account.ServerURL, doc.ToXMLString()); content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.ms-sync.wbxml"); string caps = ZPushCapabilities.Client.ToString(); Logger.Instance.Trace(this, "Sending request: {0} -> {1}: {2}", _account.Account.ServerURL, caps, doc.ToXMLString()); content.Headers.Add(Constants.ZPUSH_HEADER_CLIENT_CAPABILITIES, caps); using (HttpResponseMessage response = _client.PostAsync(url, content, _cancel).Result) { return(new Response(response)); } } }
public WBXMLInspector() { wbxmlDoc = new WBXMLDocument(); wbxmlDoc.VersionNumber = 1.3; wbxmlDoc.TagCodeSpace = new ActiveSyncCodeSpace(); wbxmlDoc.AttributeCodeSpace = new ActiveSyncAttributeCodeSpace(); wbxmlDoc.Encoding = Encoding.UTF8; xmlView = new XMLView(); textView = new RawView(this); rawBody = null; validHeader = false; tagPageControl = null; }
public Response(HttpResponseMessage response) { Logger.Instance.Trace(this, "Response received: {0} {1}\n{2}", (int)response.StatusCode, response.ReasonPhrase, response.Headers); // Check for ZPush headers // GAB name is now hex encoded, but also support old-style for transition string gabNameOrig = GetStringHeader(response, Constants.ZPUSH_HEADER_GAB_NAME); if (gabNameOrig != null && new Regex("^[0-9a-fA-F]+$").IsMatch(gabNameOrig)) { GABName = StringUtil.HexToUtf8(gabNameOrig); } else { GABName = gabNameOrig; } Capabilities = ZPushCapabilities.Parse(GetStringHeader(response, Constants.ZPUSH_HEADER_CAPABILITIES)); ZPushVersion = GetStringHeader(response, Constants.ZPUSH_HEADER_VERSION); SignaturesHash = GetStringHeader(response, Constants.ZPUSH_HEADER_SIGNATURES_HASH); // Check for success Success = response.IsSuccessStatusCode; if (Success) { // Parse the body using (HttpContent responseContent = response.Content) { byte[] result = responseContent.ReadAsByteArrayAsync().Result; Body = new WBXMLDocument(); Body.VersionNumber = 1.3; Body.TagCodeSpace = new ActiveSyncCodeSpace(); Body.Encoding = Encoding.UTF8; Body.LoadBytes(result); } } Logger.Instance.Trace(this, "Response parsed: {0}", Body == null ? "Failure" : Body.ToXMLString()); }
/// <summary> /// Creates instance of the WapPushMessage /// </summary> /// <param name="wbxmlDocument">Tokenized XML message</param> public WapPushMessage(WBXMLDocument wbxmlDocument) : this() { this.Data = wbxmlDocument.GetWBXMLBytes(); this.ContentType = wbxmlDocument.ContentType; }