Http Request to Tally server from asp.net side



I want to communicate with tally server, I am sending this code for http request and response from tally server is:



ü ¦€.Yk{ê1±<á";…òò÷ÁŽ›¾±àBÃZe´z ú÷¨éß"íè„™ýÊwº3€åµª§µ¡5ÒÀýVÿX5¥­OIdY©çÝ/Ì$ŠË¼Zœdí¼Ã%Ö Ýø®‘}}á–À†™;r?(Û„“?xS#%öDaÊʆ$“dÊ©V´ë†g2_FªÖ.·£Ð½†/ò


my code is given below



public void Test()
{
string xmlMessage = "<ENVELOPE><HEADER> <ID>TPGETCOMPANIES</ID> <SOURCE>EA</SOURCE> <TYPE>DATA</TYPE> <CONTENT-TYPE>text/xml;charset=utf-8</CONTENT-TYPE> <SESSIONID>1408730012927569997</SESSIONID> <TALLYREQUEST>Import</TALLYREQUEST> <TARGET>TNS</TARGET> </HEADER> <BODY> <DESC> <STATICVARIABLES> <SVINCLUDE>Connected</SVINCLUDE> </STATICVARIABLES></DESC></BODY></ENVELOPE>";

string url = "http://ift.tt/1zWDJSS";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

byte[] requestInFormOfBytes = System.Text.Encoding.ASCII.GetBytes(xmlMessage);
request.Method ="POST";

request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = requestInFormOfBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(requestInFormOfBytes, 0, requestInFormOfBytes.Length);
requestStream.Close();

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader respStream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.Default);
string receivedResponse = respStream.ReadToEnd();
Label1.Text = receivedResponse;
response.Close();
respStream.Close();
}


If anyone work on this please suggest me..


No comments:

Post a Comment