magentosoapuimagento-soap-api

magento soap api v2 catalogProductInfo “Session expired. Try to relogin” error


I am trying to test magento soap "catalogProductInfo" request via SoapUI.

this is the request:

    <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
       <soapenv:Header/>
       <soapenv:Body>
          <urn:catalogProductInfo soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
              <sessionId xsi:type="xsd:string"></sessionId>
              <productId xsi:type="xsd:string">31</productId>
              <attributes xsi:type="urn:catalogProductRequestAttributes">
                  <attributes xsi:type="urn:ArrayOfString" soapenc:arrayType="xsd:string[]">sku</attributes>
             </attributes>
         </urn:catalogProductInfo>
      </soapenv:Body>
   </soapenv:Envelope>

this is the response:

   <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
           <faultcode>5</faultcode>
           <faultstring>Session expired. Try to relogin.</faultstring>
       </SOAP-ENV:Fault>
     </SOAP-ENV:Body>
  </SOAP-ENV:Envelope> 

From where I get the sessionId?


Solution

  • I solved it by running the login request:

       <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
         <soapenv:Header/>
           <soapenv:Body>
             <urn:login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
               <username xsi:type="xsd:string">username</username>
               <apiKey xsi:type="xsd:string">apikey</apiKey>
             </urn:login>
           </soapenv:Body>
         </soapenv:Envelope>
    

    then u get the sessionId in response:

        <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
          <SOAP-ENV:Body>
            <ns1:loginResponse>
              <loginReturn xsi:type="xsd:string">2764d0d32d6206b3e77a4a07d28c11a4</loginReturn>
            </ns1:loginResponse>
         </SOAP-ENV:Body>
       </SOAP-ENV:Envelope>