在Angular 5中使用XML数据发出Post请求 [英] Making Post request with XML data in Angular 5

查看:513
本文介绍了在Angular 5中使用XML数据发出Post请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是角色新手并且使用角度5.

I'm am new to angular and using angular 5.

我正在发送http post请求,我想将xml数据发送到后端作为我的后端只接受xml格式的数据。

I'm making a http post request and I want to send xml data to backend as my backend only accept data in xml format.

我已经按照一些教程但无法使其工作。请让我知道我做错了什么以及如何让它发挥作用。

I've followed some tutorials but couldn't get it to work. Please let me know what I'm doing wrong and how can I make it work.

这就是我提出请求的方式。

This is how I'm making request.

signin(){
    const headers = new HttpHeaders({responseType: 'text' , 'Content-Type': 'text/xml' }).set('Accept', 'text/xml');
    let body =  '<request>' 
                '<username>Username</username>' 
                '<password>Password</password>' 
                '</request>';
    const hdr = {headers:headers , body:body};
    console.log("Checking:  " , hdr);
    return this.http.post('https://66.128.132.126:8002/?event=account_login' , hdr);
}

这是我的控制台:
的控制台

Here is my console for this:

这是我的网络:

And here is my network:

推荐答案

默认情况下,Angular CLI发出预检请求以检查CORS: https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

By default Angular CLI made a Preflight Request in order to check CORS: https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request

您的后端似乎没有正确处理此请求。我们需要后端信息来帮助您

It seems that you backend isn't handling this request correctly. We need backend info to help you

这篇关于在Angular 5中使用XML数据发出Post请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆