Я попытался отправить информацию в службу и вернуть исходное мыльное тело, используя этот код.Возможно ли это?
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GetInfoRequest));
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://localhost/Service.svc/soap/GetDataSoap");
GetInfoRequest message = new GetInfoRequest();
message.data = new List<int>();
message.data.Add(268435458);
message.data.Add(99);
MemoryStream stream1 = new MemoryStream();
serializer.WriteObject(stream1, message);
stream1.Position = 0;
StreamReader sr = new StreamReader(stream1);
string t = sr.ReadToEnd();
ASCIIEncoding encoding = new ASCIIEncoding();
request.Timeout = 99999999;
request.ContentLength = t.Length;
//request.ContentType = "application/json";
request.Method = "POST";
request.Headers.Add("SOAPAction: \"http://localhost/Service.svc/soap/GetDataSoap\"");
request.Accept = "text/xml; charset=utf-8";
request.ContentType = "application/json; charset=utf-8";
using (Stream requestStream = request.GetRequestStream())
{
var bytes = Encoding.UTF8.GetBytes(t);
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
//serializer.WriteObject(stream1, message);
//requestStream.Flush();
}
var response = (HttpWebResponse)request.GetResponse();
var abc = new StreamReader(response.GetResponseStream()).ReadToEnd();
TextBox1.Text = abc;