开发者

Is it possible to use an asp.net page to have the get results from the server sent back as an XML file?

My application sending SMS request to Mblox XML interface through, I have get response 开发者_JAVA技巧from Mblox as XML file.

string RequestXML = GenerateRequestXML();

string uri = string.Empty; uri = "http://xml.us.mblox.com:8180/send"; 

HttpWebRequest request =(HttpWebRequest)WebRequest.Create(uri);

request.KeepAlive = false; 

request.ProtocolVersion = HttpVersion.Version11; 

request.Method = "POST";

request.ContentType = "text/xml";
HttpWebResponse respon = (HttpWebResponse)request.GetResponse()


You are almost there... You already have your response, just get a reference to ResponseStream and read the XML returned:

HttpWebResponse respon = (HttpWebResponse)request.GetResponse();
Stream receiveStream =    request.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipes the stream to a higher level stream reader with the required encoding format. 
StreamReader readStream = new StreamReader( receiveStream, encode );
//now you should be able to use readStream to get your XML. That's your homework.

See a complete example here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜