.NET 4.x Интеграция веб модуля - C#
Формулировка задачи:
Доброго дня ,народ!
Есть определенный сайт, на него есть инструкция по интеграции, где расписаны все запросы в таком виде
Грубо говоря , это бд в облаке, из которой мне нужно получать определенные данные отправляя вот такие запросы.
Проблема в том, что ни разу с веб не работал.
В интернете информация разная, но что-то конкретного я не нашел.
Если кто-нибудь укажет направление, литературу, или еще что, в сторону чего копать.
Буду весьма признателен
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ind="http://atria.cz/individuals/"> <soapenv:Header/> <soapenv:Body> <ind:getIndividualCodesByIndividualIdRequest>?</ind:getIndividualCodesByIndividualIdRequest><!--данные пользователя--> </soapenv:Body> </soapenv:Envelope>
Решение задачи: «.NET 4.x Интеграция веб модуля»
textual
Листинг программы
using System;
using System.Net;
using System.Threading;
using System.Xml;
namespace ConsoleApplication34
{
class Program
{
static void Main(string[] args)
{
Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
double lengthValue = 10.0;
string fromLengthUnit = "Centimeters";
string toLengthUnit = "Inches";
string request =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
" <soap:Body>" +
" <ChangeLengthUnit xmlns=\"http://www.webserviceX.NET/\">" +
" <LengthValue>" + lengthValue.ToString() + "</LengthValue>" +
" <fromLengthUnit>" + fromLengthUnit + "</fromLengthUnit>" +
" <toLengthUnit>" + toLengthUnit + "</toLengthUnit>" +
" </ChangeLengthUnit>" +
" </soap:Body>" +
"</soap:Envelope>";
WebClient wc = new WebClient();
wc.Headers["Content-Type"] = "text/xml; charset=utf-8";
string result = wc.UploadString("http://www.webservicex.net/length.asmx", request);
XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
XmlNamespaceManager xs = new XmlNamespaceManager(doc.NameTable);
xs.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
xs.AddNamespace("r", "http://www.webserviceX.NET/");
var resultNode = doc.DocumentElement.SelectSingleNode(
"/soap:Envelope/soap:Body/r:ChangeLengthUnitResponse/r:ChangeLengthUnitResult", xs) as XmlElement;
double resultValue = double.Parse(resultNode.InnerText);
Console.WriteLine("{0:0.###} {1} -> {2:0.###} {3}",
lengthValue, fromLengthUnit, resultValue, toLengthUnit);
}
}
}