0

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

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

Script:

<?php 
   ini_set('display_errors', 1);
   $params  = array('username' => 'soapadmin','password' => 'test@1234');
   $request = new SoapClient('http://127.0.0.1/magento2011/soap/default?wsdl&services=integrationAdminTokenServiceV1',array('soap_version' => SOAP_1_2));
   $token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken($params); 
 ?>
2
1

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(
                'http'=>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();
1
  • 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.