` 我正在使用最新版本 1.0.0 的 node-soap 库 (https://github.com/vpulim/node-soap) 测试带有 pfx 客户端证书的肥皂客户端。我遇到错误(创建 SOAP 客户端时出错:AxiosError:无法获取本地颁发者证书)。相同的 pfx 客户端证书和 pwd 在 axios 库中工作良好。请帮我找出这里的问题。 wsdl_options 似乎有些设置不正确。
I tried the following.
console.log('Test');
const soap = require("soap");
const https = require('https');
const fs = require('fs');
const url = "myWsdlUrl";
const retrieveData = {
userInput: 'Test'
};
const options = {
wsdl_options: {
method: "POST",
pfx: fs.readFileSync("./src/my-pfx-file.p12"),
passphrase: "pwd123"
}
};
console.log('Before soap.createClient');
// Create SOAP client
soap.createClient(url, options, (err:any, client:any) => {
console.log('After soap.createClient');
if (err) {
console.error('Error creating SOAP client:', err);
return;
}
const args = { getData: retrieveData };
// Call a method from the SOAP service
client.retrieveWSData(args, {}, (soapErr:any, result:any) => {
console.log('After soap.createClient');
if (soapErr) {
console.error('Error calling SOAP method:', soapErr);
return;
}
console.log('SOAP method response:', result);
});
});
-------------------------
I get the below error (occurs during soap.createClient call).
Test
Before soap.createClient
After soap.createClient
Error creating SOAP client: AxiosError: unable to get local issuer certificate
at Function.AxiosError.from (C:\\workspaces\\wrksp_nodejs_example\\soap-axios- example\\node_modules\\axios\\lib\\core\\AxiosError.js:89:14)
at RedirectableRequest.handleRequestError (C:\\softwaredistribution\\fpacdev\\workspaces\\wrksp_nodejs_example\\soap-axios- example\\node_modules\\axios\\lib\\adapters\\http.js:606:25)
at RedirectableRequest.emit (node:events:513:28)
at RedirectableRequest.emit (node:domain:489:12)
at ClientRequest.eventHandlers.\<computed\> (C:\\workspaces\\wrksp_nodejs_example\\soap-axios- example\\node_modules\\follow-redirects\\index.js:14:24)
at ClientRequest.emit (node:events:513:28)
at ClientRequest.emit (node:domain:489:12)
at TLSSocket.socketErrorListener (node:\_http_client:494:9)
at TLSSocket.emit (node:events:513:28)
at TLSSocket.emit (node:domain:489:12) {
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY',`
这是如何规避的?我也有同样的问题