我可以通过以下方式将 JSON 请求数据发布到服务器,但是如何使用 http 将 XML 结构化数据发布到服务器.
I am able to post the JSON request data to server in the following way, but how do i post XML structured data to server using http.
getAuthSeed(value) {
let params = "{'validateUsr': 'false'}";
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('params', params);
let url = 'tab-api/login/'+value.username+'/seed/false';
let options = new RequestOptions({
method: RequestMethod.Get,
url: url,
headers: headers
});
return this.http.request(new Request(options)).map(
result => {
let data = result.json();
return data;
}
)
}
示例 XML 请求:
<pi:ReqPay xmlns:pi="http:schema/">
<Head ver="1.0" ts="" orgId="" msgId=""/>
<Meta>
<Tag name="PAYRE" value=""/>
</Meta>
<Txn id="" note="" custRef="" refId="" refUrl="" ts="" type="PAY|COLLECT">
<RiskScores>
<Score provider="ci" type="TXNRISK" value=""/>
</RiskScores>
<Rules>
<Rule name="MINAMOUNT" value=""/>
</Rules>
</Txn>
</pi:ReqPay>
你应该在你的 Headers
中提到 Content-Type
作为 text/xml
> 对象
You should mention Content-Type
as text/xml
in your Headers
object
let params = "{'validateUsr': 'false'}";
let headers = new Headers();
headers.append('Content-Type', 'text/xml');
headers.append('params', params);
这篇关于angular2 使用 HTTP 发布 XML 类型的请求数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!