使用私钥使用node-js签署SOAP XML

时间:2017-06-21 10:34:19

标签: web-services sap ws-security node-soap

尝试使用我的私钥和使用SOAP UI签署XML 它给出了适当的成功反应。

使用以下代码生成请求

var Authorization = 'Basic ' + new Buffer((sapConfig.sap.username + ':' + sapConfig.sap.password) || '').toString('base64');
        soap.createClient(__dirname + '/wsdl/SI_CARWORKZ_Customer_Sen_Sync.wsdl', wsdlOptions, function (err, client) {
            client.setSecurity(new soap.WSSecurityCert(privateKey, publicKey, password, 'utf8'));   
            //client.setSecurity(new soap.ClientSSLSecurity(privateKey, publicKey, ca));    
            client.SI_CARWORKZ_Customer_Sen_Sync(details, sslOptions, function(err, result, raw, soapHeader) {
            console.log('%j', result);
            if(_.has(result, "ResponseData") && !_.isEmpty(result.ResponseData.Item)){
                var status = _.pluck(result.ResponseData.Item, "Status");
                if(status.indexOf('E') != -1){ 
                    return callback({status: "error", data: result});   
                }else{
                    // insert the user in mongodb
                    sapLogs.insertCustomers(details.HEADER, function(result){
                        console.log("customer added");                  
                        return callback({status: "success", data: details});    
                    })
                }
            }else{
                return callback({status: "error", data: [], message: "something went wrong." })
            }
            }, {"Authorization": Authorization});   
        });

但是当我使用脚本发送签名的xml数据时,它会显示错误

Error while valdiating the digital signature. The error was java.lang.NullPointerException while trying to invoke the method com.sap.security.core.ws.wss.tokens.securitytoken.BinarySecurityToken.getSecurityToken()

我的公钥或私钥有问题吗?
我已经从在SOAP UI中使用的 jks 文件中导出它们。

0 个答案:

没有答案