1

我想发送类型为“text/xml”的 HTTP POST 请求以及请求,我将 Querystring 值发送为:

"?wicket:interface=:9:XXOIForm:transactionForm:componentListPanel:componentListView:0:component:expressEntryContainer:expressEntry::IBehaviorListener:0:&wicket:pcxt=XXOIForm&random=0.48316250719134435"

这是我手动添加的几个请求标头

request.Headers.Add("Accept-Language", "en-us,en;q=0.5");
request.Headers.Add("Wicket-Ajax", "true");
request.Headers.Add("Wicket-FocusedElementId", "id1a");

我通过 HTTP Anlayzer 工具记录的所有日志。

但我无法绕过这个请求。请建议我有什么方法可以发送类型为 HTTP POST 的请求"text/xml"吗?

或者我需要在请求标头中发送什么?

是的,我仅以字节流格式发送帖子数据请参阅我有以下代码来发送帖子数据

protected void WritePostDataToRequest(string postData)
    {

        postData = postData.Replace("/", "%2F").Replace(",", "%2C").Replace(" ", "+").Replace("!", "%21").Replace("#", "%23");
        data = encoding.GetBytes(postData);
        request.ContentLength = data.Length;
        newStream = request.GetRequestStream();
        newStream.Write(data, 0, data.Length);
        newStream.Close();
    }

此外,我已经添加了请求标头内容类型。

提前致谢...

4

2 回答 2

3
request.ContentType = 'text/xml';
于 2012-10-11T04:56:30.720 回答
1

使用字节流发送你的数据:

string data="wicket:interface=:9:eligibitiyBenefitsInquiryForm:transactionForm:componentListPanel:componentListView:0:component:expressEntryContainer:expressEntry::IBehaviorListener:0:&wicket:pcxt=EligibilityBenefitInquiryPage&random=0.48316250719134435"

byte[] dataStream = Encoding.UTF8.GetBytes(data);    
string uriStr = "www.abc.com";
HttpWebRequest rqst = (HttpWebRequest)HttpWebRequest.Create(Uri.EscapeUriString(uriStr));
rqst.KeepAlive = false;
rqst.Method = "POST";


rqst.ContentType = "application/x-www-form-urlencoded";
rqst.ContentLength = dataStream.Length;
Stream newStream = rqst.GetRequestStream();

newStream.Write(dataStream, 0, dataStream.Length);
newStream.Close();
WebResponse resp = rqst.GetResponse();
于 2012-10-11T05:03:02.727 回答