SOAP node returns error Target-Namespace “undefined” already in use by another Schema

前端 未结 4 2050
無奈伤痛
無奈伤痛 2020-12-31 22:43

I\'m trying to write a client for russian post to get track. It uses SOAP WSDL. I\'m to get at least client object.

 \'use strict\'
let soap=require(\'soap\         


        
4条回答
  •  生来不讨喜
    2020-12-31 23:26

    Solved. Workaround of issue. First instead of their .wsdl file I use modified original wsdl file and store it locally.

    workaround of xml file Fixed it by adding into schema targetnNamespace parameter.

    
    
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
    
    
        
    
    

    Original wsdl code part

        
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
        
            
        
    
    
        
    
    

    now to use our wsdl file:

    var SoapClient = require('soap');
    var options = {
        'trace': 1,
        "overrideRootElement": {
            "namespace": "myns",
            "xmlnsAttributes": [{
                "name": "xmlns:ns2",
                "value": "http://russianpost.org/operationhistory"
            }]
        },
        forceSoap12Headers: true,
        connection: 'keep-alive',
        'soap_version': 2
    };
    SoapClient.createClient('./local_wsdl.xml', options, function (err, client) {
        client.getOperationHistory(
            {
            'ns1:OperationHistoryRequest': {
                'ns1:Barcode': trackValue,
                'ns1:MessageType': 0,
                'ns1:Language': 'RUS',
            },
            'ns1:AuthorizationHeader': {
                'ns1:login': login,
                'ns1:password': password,
            },
        },
        (err, result) => {
            if (err) {
                console.log(err);
    
                return;
            }
    
            console.log(result.OperationHistoryData);
        }
        );
    }
    

提交回复
热议问题