xml – node-soap客户端(Node.js)中数组字段的命名空间
发布时间:2020-12-16 23:22:14 所属栏目:百科 来源:网络整理
导读:如何为数组配置node-soap客户端集命名空间不仅适用于对象? 我对’sendPatient’方法的参数: params = { patientCard: { patient: { firstName: 'test',lastName: 'test' },identifiers: { code: "123456789",codeType: 1 } } };client.sendPatient(params,
|
如何为数组配置node-soap客户端集命名空间不仅适用于对象?
我对’sendPatient’方法的参数: params = {
patientCard: {
patient: {
firstName: 'test',lastName: 'test'
},identifiers:
{
code: "123456789",codeType: 1
}
}
};
client.sendPatient(params,...)
node-soap产品: <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',identifiers: [
{
code: "123456789",codeType: 1
},{
code: "987654321",codeType: 2
}
]
}
};
node-soap产品: <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也可以为数组添加它(不仅仅是简单的对象)? 解决方法
发布临时解决方案
on Github
在createClient补丁wsdl定义之后 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(...)
});
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
