繁体   English   中英

如何发送类型为“text / xml”的HTTP POST请求

[英]How to send HTTP POST request which is of type “text/xml”

我想发送类型为“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工具记录的所有日志。

但我无法绕过这个请求。 请建议我有没有办法发送类型为"text/xml"的HTTP POST请求?

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

是的我只发送字节流格式的发布数据请参阅我有以下代码发送发布数据

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();
    }

我还添加了请求标头内容类型。

提前致谢...

request.ContentType = 'text/xml';

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

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();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM