【发布时间】:2021-03-17 16:17:46
【问题描述】:
我正在使用 React 开发一个项目,我必须将 XML 发送到端点,但是当我这样做时,我收到了 Forbidden 403 错误。我包括凭据和无证书
fetch('https://cors-anywhere.herokuapp.com/http://endpoint', {
method: 'POST',
mode: 'no-cors',
credentials: 'include',
headers: (
{'Content-Type': 'application/json;text/xml; charset=utf-8',
"SOAPAction": "urn:schemas-upnp-org:service:RenderingControl:1#GetVolume",
'Accept-Language': 'en-GB',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'Keep-alive',
'Content-Length': Content.length
}),
body: Content
}).then(function (response) {
toast("Procesado correctamente");
}).catch(function (error) {
toast("Error al procesar");
});
这是我要发送的 xml
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/"> <soap:Header/><soap:Body><tem:ImportarXML><!--Optional:--> <tem:pvstrDatos><![CDATA[<Importar><NombreConexion>Pruebas</NombreConexion><IdCia>1</IdCia><Usuario>auxvtamed2</Usuario><Clave>lufe3698</Clave><Datos> <Linea>000000100000001001</Linea><Linea>000000204050011001001CPV000021660000000SEELENSAF +18.00 00101 S2019106199 Und 000000000000001.0000000000000000000.00000000012332</Linea><Linea>000000304050011001001CPV000021660000000SEELENSAF +18.50 00101 S2019113899 Und 000000000000001.0000000000000000000.00000000012333</Linea><Linea>000000404050011001001CPV000021660000000SEELENSAF +19.00 00101 S2019107799 Und 000000000000001.0000000000000000000.00000000012334</Linea><Linea>000000504050011001001CPV000021660000000SEELENSAF +19.50 00101 S2019110199 Und 000000000000001.0000000000000000000.00000000012335</Linea><Linea>000000699990001001</Linea> </Datos></Importar>]]></tem:pvstrDatos> <tem:printTipoError>0</tem:printTipoError> </tem:ImportarXML></soap:Body></soap:Envelope>
【问题讨论】:
标签: javascript reactjs xml axios fetch