#javascript #node.js #soap #soapui
#javascript #node.js #soap #soapui
Вопрос:
Я пытаюсь использовать SoapUI с узлом js, у меня есть сервер узла с функцией, которая вычисляет с 2 целыми числами.
Мой объект :
{
attributes: {
'soapenv:encodingStyle': 'http://schemas.xmlsoap.org/soap/encoding/'
},
weight: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' },
distance: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' }
}
И мне нужно сохранить только
{ weight: '10', distance: '10' }
Я пытаюсь что-то сделать args.weight.attributes['$value']
, но ничего не получается.
Есть идеи?
И невозможно изменить этот формат возврата wsdl soap?
Ответ №1:
вы должны использовать:
args.weight['$value']
args.distance['$value']
let args = {
attributes: {
'soapenv:encodingStyle': 'http://schemas.xmlsoap.org/soap/encoding/'
},
weight: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' },
distance: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' }
}
console.log(args.weight['$value'])
console.log(args.distance['$value'])
Ответ №2:
Я надеюсь, что это будет полезно для вас:
{ weight: obj.weight['$value'], distance: obj.distance['$value'] }
let obj = {
attributes: {
'soapenv:encodingStyle': 'http://schemas.xmlsoap.org/soap/encoding/'
},
weight: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' },
distance: { attributes: { 'xsi:type': 'xsd:int' }, '$value': '10' }
}
console.log(
/*return*/{
weight: obj.weight['$value'],
distance: obj.distance['$value']
}
)