Adding soap header in client using soap module in node.js

I am very new to salesforce and trying to create a SOAP client that will connect and fetch details from the salesforce for a particular lead.

I am consuming partner wsdl.

As of now I am able to create client using the partner wsdl.

I have set the session header as given in this

However when I am trying to fetch some information it's giving me error related to the session header

   <?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>sf:INVALID_SESSION_ID</faultcode>
         <faultstring>INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session</faultstring>
         <detail>
            <sf:UnexpectedErrorFault xsi:type="sf:UnexpectedErrorFault">
               <sf:exceptionCode>INVALID_SESSION_ID</sf:exceptionCode>
               <sf:exceptionMessage>Invalid Session ID found in SessionHeader: Illegal Session</sf:exceptionMessage>
            </sf:UnexpectedErrorFault>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

I am setting the session header like this

var sheader = {
                        SessionHeader : {
                            sessionId: result.result.sessionId
                        }
                    };

                    client.addSoapHeader(sheader);

I am using soap node module for creating the SOAP client, which says the session header to be set like this.

Now my question is from where can I get these three optional information i.e.

  • name Unknown parameter (it could just a empty string)
  • namespace prefix of xml namespace
  • xmlns URI

Any guidance will be helpful here considering I am fairly new to SOAP and Salesforce.

Replace this client.addSoapHeader(sheader,"","tns",""); with

client.addSoapHeader(sheader,"","tns","urn:partner.soap.sforce.com");