Есть у меня задачка. Необходимо отправлять и принимать ответы от веб-сервиса. Вот данные из инструкции.
Request and response information is transmitted by placing an XML document in the POST payload of the HTTPS request. To integrate with the iCRS system, do the following: 1. Build/Use a client program that can operate with the HTTPS protocol. There are no restrictions on the type of client program used, providing it can use this protocol and deal with transactions synchronously. 2. Build/Use a program that can build a valid request XML document (see specification in Appendix A) and attach it via a POST parameter to a HTTPS request. POST / HTTP/1.0 UserAgent: HTTPTool/1.0 ContentType: text/xml Post Payload 3. Build/Use a program that can retrieve the HTTPS response and process the binary file output, which includes the XML payload and attached digital signature. See the Extracting the XML Output section on page 9. 4. Build/Use a program that can correctly interpret the inquiry response information within the XML return.
Т.е. на сколько я понял, необходимо создать XML и обычным POST запросом отправить, и получить ответ?
XML делаю обычным XElement
XElement xml = new XElement("Product",
new XElement("prequest",
new XElement("req",
new XElement("AddressReq",
new XElement("street", "Горького"),
new XElement("houseNumber", "1"),
new XElement("apartment", "38"),
new XElement("city", "Магадан"),
new XElement("postal", "685000"),
new XElement("addressType", "1")))));
Далее делаю запрос и ответ:
Console.WriteLine(xml);
Console.ReadKey();
WebRequest request = WebRequest.Create("http://websevice.com/url");
byte[] byteArray = Encoding.GetEncoding(1251).GetBytes(xml.ToString());
request.Method = "POST";
request.ContentType = "text/xml";
request.ContentLength = byteArray.Length;
Stream data = request.GetRequestStream();
data.Write(byteArray, 0, byteArray.Length);
data.Close();
Console.ReadKey();
WebResponse response = request.GetResponse();
Console.WriteLine(((HttpWebResponse)response).StatusDescription);
data = response.GetResponseStream();
StreamReader reader = new StreamReader(data);
string responseFromServer = reader.ReadToEnd();
Console.WriteLine(responseFromServer);
reader.Close();
data.Close();
response.Close();
Console.ReadKey();
Вопрос. Правильно ли я все делаю?
Кофе для программистов: как напиток влияет на продуктивность кодеров?
Рекламные вывески: как привлечь внимание и увеличить продажи
Стратегії та тренди в SMM - Технології, що формують майбутнє сьогодні
Выделенный сервер, что это, для чего нужен и какие характеристики важны?
Современные решения для бизнеса: как облачные и виртуальные технологии меняют рынок
Есть дата сет с кучей ChildRelations связейСвязи называются ТаблицаГлавная_ПотомокГлавной, и так внутрь до 6 вложений
Мне нужно запустить в консольном приложение 3 асинхронных 3 методаКаждый метод создает бесконечный цикл в котором обрабатывает данные из источника...
Есть кастомное окно, как сделать в MVVM dragmove для него? Как и где правильно забиндить mouse event?