Namespace for array field in node-soap client (Node.js)

How do I set up a node namespace for a set of wrapper names for an array not just for objects?

My parameters for the sendPatient method:

params = {
        patientCard: {
          patient: {
            firstName: 'test',
            lastName: 'test'
          },
          identifiers:
            {
              code: "123456789",
              codeType: 1
            }
        }
      };
client.sendPatient(params, ...)

      

node-image:

<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>

      

and it works, but I need to send an array of ids, not just one, so when I put the array

params = {
        patientCard: {
          patient: {
            firstName: 'test',
            lastName: 'test'
          },
          identifiers: [
            {
              code: "123456789",
              codeType: 1
            }, {
              code: "987654321",
              codeType: 2
            }
          ]
        }
      };

      

node-image:

<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>                                                   

      

and I get an error from the server for <ns1:identifiers>

part

`[com.ctc.wstx.exc.WstxParsingException: Undeclared namespace prefix "ns1" at [row,col {unknown-source}]: [17,25]]`

      

What am I doing wrong? Is it possible to somehow add a tag xmlns:ns1="http://xxx/patient/"

to <soap:Envelope>

or customize node-soap to add it for arrays too (not just simple objects)? Postscript Sorry for my english

+3


source to share


1 answer


Published workaround on Github

after defining wcld patches creatClient



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(...)
});

      

+9


source







All Articles