[SalesForce] Get sessionId/ serverUrl with login webservice soapUI

By using "Generate Enterprise WSDL " I got the below login webservice for my salesforce org.

Login webservice

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:LoginScopeHeader>
         <urn:organizationId>?</urn:organizationId>
         <!--Optional:-->
         <urn:portalId>?</urn:portalId>
      </urn:LoginScopeHeader>
   </soapenv:Header>
   <soapenv:Body>enter preformatted text here
      <urn:login>
         <urn:username>username</urn:username>
         <urn:password>"mypassword+securitytoken"</urn:password>
      </urn:login>
   </soapenv:Body>


</soapenv:Envelope>

After running this in SOAP UI, I did not get the sessionId/ serverUrl.
The error I got as below:

Output

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sf="urn:fault.enterprise.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>INVALID_LOGIN</faultcode>
         <faultstring>INVALID_LOGIN: malformed id: organizationId '?'</faultstring>
         <detail>
            <sf:LoginFault xsi:type="sf:LoginFault">
               <sf:exceptionCode>INVALID_LOGIN</sf:exceptionCode>
               <sf:exceptionMessage>malformed id: organizationId '?'</sf:exceptionMessage>
            </sf:LoginFault>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

Best Answer

You don't need to define the <urn:LoginScopeHeader> as part of the login API call unless you are authenticating a Self-Service user against a specific org and portal. If that isn't the case you can safely omit that header.

Related Topic