I have to make Xml post request to an Api, and don't know what am missing, am always getting two erros. and my request is..
string oRequest = "";
oRequest = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\""
+"xmlns:typ=\"http://www.website.net/lmsglobal/ws/v1/extint/types\""
+"xmlns:typ1=\"http://www.website.net/lmsglobal/xsd/v1/types\">";
oRequest = oRequest + "<soapenv:Header/>";
oRequest = oRequest + "<soapenv:Body>";
oRequest = oRequest + "<typ:GetAccountBalanceRequest>";
oRequest = oRequest + "<typ:Authentication>";
oRequest = oRequest + "<typ1:Principal>";
oRequest = oRequest + "<typ1:PrincipalValue >88888888888</ typ1:PrincipalValue>";
oRequest = oRequest + "<typ1:PrincipalClassifier >0</ typ1:PrincipalClassifier>";
oRequest = oRequest + "</typ1:Principal>";
oRequest = oRequest + "</typ:Authentication>";
oRequest = oRequest + "</typ:GetAccountBalanceRequest>";
oRequest = oRequest + "</soapenv:Body>";
oRequest = oRequest + "</soapenv:Envelope>";
byte[] data = Encoding.UTF8.GetBytes(oRequest);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://mywebsite.in/Services/v1/soap");
request.Method = "POST";
request.ContentType = "text/xml;charset=UTF-8";
Stream dataStream = request.GetRequestStream();
dataStream.Write(data, 0, data.Length);
dataStream.Close();
HttpWebResponse resp = (HttpWebResponse)request.GetResponse();
string result = new StreamReader(resp.GetResponseStream()).ReadToEnd();
errors:
((System.Net.ConnectStream)newStream).Length threw an exception of type 'System.NotSupportedException'
((System.Net.ConnectStream)newStream).Lengththrew an exception of type 'System.NotSupportedException' getting these errors at
Stream dataStream = request.GetRequestStream();
and finally 500 internal server error. what am i missing any thing is wrong ? and this request when do from SOAP UI tools it's giving responce too.