I tried to generate token for magento2 SOAP API but i am getting below error


Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] SoapServer::SoapServer(): Invalid parameters in /var/www/html/magento2011/test.php:36 Stack trace: #0 /var/www/html/magento2011/test.php(36): SoapClient->__call('integrationAdmi...', Array) #1 {main} thrown in /var/www/html/magento2011/test.php on line 36


   ini_set('display_errors', 1);
   $params  = array('username' => 'soapadmin','password' => 'test@1234');
   $request = new SoapClient('',array('soap_version' => SOAP_1_2));
   $token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken($params); 

Try below code, this works for me:-

$request = new SoapClient("http://localhost/magento2sample/soap/?wsdl&services=integrationAdminTokenServiceV1");
 $token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken(array("username"=>"XXX", "password"=>"XXX"));

    $opts = array(
                    'header' => 'Authorization: Bearer '.json_decode($token->result)

    $wsdlUrl = 'http://localhost/magento2sample/soap/default?wsdl&services=serviceName';

    $context = stream_context_create($opts);
    $soapClient = new SoapClient($wsdlUrl, ['version' => SOAP_1_2, 'context' => $context]);

    $soapResponse = $soapClient->__getFunctions();
  • i tried with this code. the issue is token is not generating and i am getting below issue at the time "Uncaught SoapFault exception: [SOAP-ENV:Server] SoapServer::SoapServer(): Invalid parameters". – Ramesh May 2 '17 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.