请求失败,状态码为415 axios

时间:2020-07-06 13:06:02

标签: node.js cookies soap google-cloud-platform axios

我是新加入的肥皂和云端功能。 登录后,我致电soap Web服务(凭据是cookie),但始终返回请求失败,状态码为415:

 const qs = require('qs');
 const axios = require('axios');

 var xmls = `<?xml version="1.0" encoding="utf-8"?>
 <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap- 
 envelope">
  <soap12:Body>"xml"</soap12:Body>
</soap12:Envelope>`
exports.myfunc = (req1, res1) => {
var data = qs.stringify({
  login: 'login',
  sha1Password:'password'
});
axios({
  method: 'post',
  url:'url',
  data,
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': data.length
  },
})
.then((res) => {
  axios.post('url',
           xmls,
           {withCredentials: true},
           {headers:
             {'Content-Type': 'application/soap+xml; charset=utf-8'}
           }).then(resp=>{
             console.log('res', resp);
           }).catch(err=>{console.log('soapErr', err.message)});
  res1.end();
})
.catch((error) => {
    console.log('hi from err');
  console.log(error.message)
})
};

0 个答案:

没有答案