【发布时间】:2019-07-03 01:57:28
【问题描述】:
我是 SOAP 协议的新手,在生产环境中使用它之前尝试了一个工作测试 API。我在通过 SOAP 成功连接时遇到了一些问题
我研究了数周的帖子,尝试了 easy-soap-request、soap-node、axios 和其他模块,但没有成功。
const soapRequest = require('easy-soap-request');
const fs = require('fs');
// example data
const url = 'http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL';
const headers = {
'soapAction': '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.oorsprong.org/websamples.countryinfo">' +
'<soapenv:Header/>' +
'<soapenv:Body>' +
'<web:CountryName>' +
'<web:sCountryISOCode>COL</web:sCountryISOCode>' +
'</web:CountryName>' +
'</soapenv:Body>' +
'</soapenv:Envelope>'
};
const xml = fs.readFileSync('test/zipCodeEnvelope.xml', 'utf-8');
// usage of module
(async () => {
const { response } = await soapRequest(url, headers, xml, 1000); //
Optional timeout parameter(milliseconds)
const { body, statusCode } = response;
console.log(body);
console.log(statusCode);
})();
下面列出的错误消息。
C:\Program Files\nodejs>node test.js
SOAP FAIL: Error: Request failed with status code 500
(node:14196) UnhandledPromiseRejectionWarning:
C:\Program Files\nodejs>node test.js
SOAP FAIL: Error: Request failed with status code 415
(node:14836) UnhandledPromiseRejectionWarning: The server cannot service the request because the media type is unsupported.
(node:14836) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:14836) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
【问题讨论】: