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

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

问题描述

我是 angular 的新手,我正在使用 angular 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);
}

这是我的控制台:

这是我的网络:

推荐答案

默认情况下,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天全站免登陆