Пространство имен для поля массива в клиенте мыла узла (Node.js)
Как настроить клиентское мыльное пространство имен для массива, а не только для объектов?
Мои параметры для метода sendPatient:
params = {
patientCard: {
patient: {
firstName: 'test',
lastName: 'test'
},
identifiers:
{
code: "123456789",
codeType: 1
}
}
};
client.sendPatient(params, ...)
Нод-мыло производят:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://xxx/patient/api/"
xmlns:bi="http://xxx/base/info/build/">
<soap:Header></soap:Header>
<soap:Body>
<tns:sendPatient
xmlns:tns="http://xxx/patient/api/"
xmlns="http://xxx/patient/api/">
<tns:patientCard>
<ns1:patient
xmlns:ns1="http://xxx/patient/">
<ns1:firstName>test</ns1:firstName>
<ns1:lastName>test</ns1:lastName>
</ns1:patient>
<ns1:identifiers
xmlns:ns1="http://xxx/patient/">
<ns1:code>123456789</ns1:code>
<ns1:codeType>1</ns1:codeType>
</ns1:identifiers>
</tns:patientCard>
</tns:sendPatient>
</soap:Body>
</soap:Envelope>
и это работает, но мне нужно отправить массив идентификаторов, а не только один, поэтому, когда я ставлю массив
params = {
patientCard: {
patient: {
firstName: 'test',
lastName: 'test'
},
identifiers: [
{
code: "123456789",
codeType: 1
}, {
code: "987654321",
codeType: 2
}
]
}
};
Нод-мыло производят:
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="http://xxx/patient/api/"
xmlns:bi="http://xxx/base/info/build/">
<soap:Header></soap:Header>
<soap:Body>
<tns:sendPatient
xmlns:tns="http://xxx/patient/api/"
xmlns="http://xxx/patient/api/">
<tns:patientCard>
<ns1:patient
xmlns:ns1="http://xxx/patient/">
<ns1:firstName>test</ns1:firstName>
<ns1:lastName>test</ns1:lastName>
</ns1:patient>
<ns1:identifiers>
<ns1:code>00100180035</ns1:code>
<ns1:codeType>1</ns1:codeType>
</ns1:identifiers>
<ns1:identifiers>
<ns1:code>00100180035</ns1:code>
<ns1:codeType>1</ns1:codeType>
</ns1:identifiers>
</tns:patientCard>
</tns:sendPatient>
</soap:Body>
</soap:Envelope>
и я получаю ошибку от сервера для <ns1:identifiers>
часть
`[com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "ns1" at [row,col {unknown-source}]: [17,25]]`
Что я делаю неправильно? Могу ли я как-то добавить xmlns:ns1="http://xxx/patient/"
в <soap:Envelope>
пометить или настроить node-soap, чтобы добавить его и для массивов (не только для простых объектов)?
PS извините за мой английский
1 ответ
Опубликовано временное решение на Github
после создания wsdl патча createClient
soap.createClient(wsdl, options, function(err, client) {
client.wsdl.definitions.xmlns.ns1 = 'http://xxx/patient/'
client.wsdl.xmlnsInEnvelope = client.wsdl._xmlnsMap()
//works now
client.sendPatient(...)
});
В машинописи вы можете получить доступ к частному WSDL как Смуглые комментарии, но прилагая имена непосредственно:
client['wsdl'].xmlnsInEnvelope += 'xmlns:ns1="http://xxx/patient/"';
client['wsdl']._xmlnsMap();