2

I'm creating a soap server using vpulim/node-soap.
Everything works well except one thing.
The result of my request is this one :

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:tns="http://tempuri.org/">
    <soap:Body>
        <tns:StatelessImportEntityResponse>
            <tns:return>something</tns:return>
        </tns:StatelessImportEntityResponse>
    </soap:Body>
</soap:Envelope>

But the client that calls me needs this : (the difference is the 'tns' namespace removed from the return tag)

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"  xmlns:tns="http://tempuri.org/">
    <soap:Body>
        <tns:StatelessImportEntityResponse>
            <return>something</return>
        </tns:StatelessImportEntityResponse>
    </soap:Body>
</soap:Envelope>

So I'm trying to remove the namespace but without any success, I tried using the overrideRootElement wsdl option like in the example here which seems to do exactly what I want but in my side it is not working... I used it like this :

soap.listen(mailRouterServer.server, {
   path: '/mailRouter',
   services,
   xml,
   overrideRootElement: {
      namespace: 'xmlns:tns',
      xmlnsAttributes: [{
        name: 'xmlns:ns2',
        value: 'http://tempuri.org/'
      }, {
        name: 'xmlns:ns3',
        value: 'http://sillypets.com/xsd'
      }]
   }
})

For the moment I used this as a workaround :

soapServer.on('response', (response) => {
     response.result = response.result.replace(/tns:return/g, 'return');
});

But it feels really really bad :(

0 Answers0