XML Request и ошибка "Недопустимая лексема "=" в объявлении класса, структуры или интерфейса" - C#
Формулировка задачи:
Пишу отправку xml запроса,компилятор ругается.
req.ContentType = "text/xml";
req.Method = "POST";
req.ContentLength = bytes.Length; - в этих строчках"Ошибка 1 Недопустимая лексема "=" в объявлении класса, структуры или интерфейса"
Что делаю не так?У кого какие мысли по этому поводу?
using System;
using System.Configuration;
using System.Data;
using System.Net;
using System.Linq;
using System.Web;
using System.Security;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Text;
namespace UnderMain
{
public static class Request
{
static string url = "https://website.com";
static string postData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <request version=\"1.0\"> <merchant><id>i123</id> <signature>"+rhcp+"</signature> </merchant><data><oper>prp</oper></data> </request>";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(postData);
static string pass = "Password";
static var code = System.Security.Cryptography.MD5.Create(pass);
static var rhcp= System.Security.Cryptography.SHA1.Create(code);
var req = (HttpWebRequest)WebRequest.Create("https://website.com");
req.ContentType = "text/xml";
req.Method = "POST";
req.ContentLength = bytes.Length;
using (Stream os = req.GetRequestStream());
{
os.Write(bytes, 0, bytes.Length);
}
string response = "";
using (System.Net.WebResponse resp = req.GetResponse())
{
using (StreamReader sr = new StreamReader(resp.GetResponseStream()))
{
response = sr.ReadToEnd().Trim();
}
}
}
}Решение задачи: «XML Request и ошибка "Недопустимая лексема "=" в объявлении класса, структуры или интерфейса"»
textual
Листинг программы
using System;
using System.Configuration;
using System.Data;
using System.Net;
using System.Linq;
using System.Web;
using System.Security;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Text;
namespace UnderMain
{
public static class Request
{
public static void Responce()
{
var pass = "Password";
var code = System.Security.Cryptography.MD5.Create(pass);
var rhcp = System.Security.Cryptography.SHA1.Create(code.ToString());
var url = "https://website.com";
var postData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <request version=\"1.0\"> <merchant><id>i123</id> <signature>" + rhcp + "</signature> </merchant><data><oper>prp</oper></data> </request>";
var bytes = System.Text.Encoding.ASCII.GetBytes(postData);
var req = (HttpWebRequest)WebRequest.Create(url);
req.ContentType = "text/xml";
req.Method = "POST";
req.ContentLength = bytes.Length;
using (var os = req.GetRequestStream())
{
os.Write(bytes, 0, bytes.Length);
}
string response = "";
using (var resp = req.GetResponse())
{
using (var sr = new StreamReader(resp.GetResponseStream()))
{
response = sr.ReadToEnd().Trim();
}
}
}
}
}