对于我在Node.js中使用soap模块时遇到的错误,解决方案是什么

5q4ezhmt  于 2023-01-25  发布在  Node.js
关注(0)|答案(1)|浏览(162)

我使用Node.js中的soap模块,如下所示

import soap  from "soap";

        const ADRES = 'https://tckimlik.nvi.gov.tr/service/kpspublic.asmx?WSDL';
        let degerler = {
        TCKimlikNo: 11111111111,
        Ad: 'YUSUF SEFA',
        Soyad: 'SEZER',
        DogumYili: 1111
        };

        soap.createClient(ADRES, (err, client) =\> {

        client.TCKimlikNoDogrula(degerler, (err, result) =\> {
        if (result.TCKimlikNoDogrulaResult) {
        console.log('information is correct');
        } else {
        console.log('Information is incorrect');
        }
        });

        });

但是,我得到了以下错误作为输出。

PS C:\\laragon\\www\\node-soap\> npm start

        > soap@1.0.0 start
        > node app.js

        C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\http.js:40
        this.\_request = options.request || req\["default"\].create();
        ^

        TypeError: Cannot read properties of undefined (reading 'create')
        at new HttpClient (C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\http.js:40:59)
        at Object.open_wsdl (C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\wsdl\\index.js:1270:48)
        at openWsdl (C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\soap.js:70:16)
        at C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\soap.js:48:13
        at \_requestWSDL (C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\soap.js:76:9)
        at Object.createClient (C:\\laragon\\www\\node-soap\\node_modules\\soap\\lib\\soap.js:94:5)
        at file:///C:/laragon/www/node-soap/app.js:12:6
        at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
        at async Promise.all (index 0)
        at async ESMLoader.import (node:internal/modules/esm/loader:526:24)
        PS C:\\laragon\\www\\node-soap\>

软件包. json内容

{
        "name": "soap",
        "version": "1.0.0",
        "description": "",
        "main": "app.js",
        "type": "module",

        "scripts": {
        "test": "echo "Error: no test specified" && exit 1",
        "start": "node app.js"
        },
        "author": "",
        "license": "ISC",
        "dependencies": {
        "express": "^4.18.2",
        "nodemon": "^2.0.20",
        "soap": "^0.45.0"
        }
        }

这个错误的原因是什么?尽管我在网上搜索了所有的东西,但我还是没有找到解决这个问题的方法。是版本有问题吗?错误在哪里,因为这个错误我不能试用这个信徒的soap模块。

sczxawaw

sczxawaw1#

如果我没弄错的话,import soap from soap是python语法,这似乎没有任何问题:

var soap = require('soap');

        const ADRES = 'https://tckimlik.nvi.gov.tr/service/kpspublic.asmx?WSDL';
        let degerler = {
        TCKimlikNo: 11111111111,
        Ad: 'YUSUF SEFA',
        Soyad: 'SEZER',
        DogumYili: 1111
        };

soap.createClient(ADRES, (err, client) => {
    client.TCKimlikNoDogrula(degerler, (err, result) => {
        if (result.TCKimlikNoDogrulaResult) {console.log('True'); } 
        else {console.log('False'); }
    });
    
});

相关问题