2010-11-29 40 views

回答

7

作爲開始請參閱

1- HttpWebRequest類

2- HttpWebResponse類

3- WebClient類

在MSDN

請參閱Here

4

這不是' t在C#中,但你應該能夠解釋它。

var 
    Bytes: Array of Byte; 
    Request: HttpWebRequest; 
    RequestStream: Stream; 
    Response: HttpWebResponse; 
    ResponseStream: StreamReader; 
begin 
    Bytes := Encoding.UTF8.GetBytes(Data); //Where data is your data (XML in my case) 
    Request := WebRequest.CreateDefault(Uri.Create(URL)) as HttpWebRequest; 
    Request.Method := 'POST'; 
    Request.ContentLength := Length(Bytes); 
    Request.ContentType := 'application/xml'; //Set accordingly 

    RequestStream := Request.GetRequestStream; 
    RequestStream.Write(Bytes, 0, Length(Bytes)); 
    RequestStream.Close; 

    Response := Request.GetResponse as HttpWebResponse; 
    ResponseStream := StreamReader.Create(Response.GetResponseStream, Encoding.ASCII); 
    Result := ResponseStream.ReadToEnd; 
    ResponseStream.Close; 

如果您需要澄清,請告訴我。

+0

好像德爾福 – Lucas 2016-10-13 19:17:47

相關問題