Пример #1
0
        string XmlEcho(string message)
        {
            var xmlString  = XmlSerializationHelpers.Serialize(message);
            var xmlContent = new StringContent(xmlString, Encoding.UTF8, "application/xml");

            using (var response = _httpClient.PostAsync($"xml/{_v0VersionUrl}echo", xmlContent).Result)
            {
                response.EnsureSuccessStatusCode();
                var content = response.Content.ReadAsStringAsync().Result;

                return(content);
            }
        }
Пример #2
0
        private async Task <EchoResponse> XmlEchoAsync(EchoRequest message)
        {
            var xmlString  = XmlSerializationHelpers.Serialize(message);
            var xmlContent = new StringContent(xmlString, Encoding.UTF8, "application/xml");

            using (var response = await _httpClient.PostAsync("v1/Echo", xmlContent))
            {
                response.EnsureSuccessStatusCode();
                var content = await response.Content.ReadAsStringAsync();

                var    xml      = XElement.Parse(content);
                string jsonText = JsonConvert.SerializeXNode(xml);
                return(JsonConvert.DeserializeObject <EchoResponse>(jsonText));
            }
        }