0

Can't use soap service When I test soap with this script:

try {
$opts = array(
            'http'=>array(
                'header' => 'Authorization: Bearer token'
            )
        );
$wsdlUrl = 'https://host/soap/default?wsdl=1&services=testModule1AllSoapAndRestV1';
$serviceArgs = array("id"=>1);

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

$soapResponse = $soapClient->testModule1AllSoapAndRestV1Item($serviceArgs); 
}
catch (Exception $e) {
    echo $e;
}

I get this error:

SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://host/soap/default?wsdl=1&services=testModule1AllSoapAndRestV1' : failed to load external entity "https://host/soap/default?wsdl=1&services=testModule1AllSoapAndRestV1" in /var/www/vhosts/host/httpdocs/scripts/soaptest.php:12 Stack trace: #0 /var/www/vhosts/host/httpdocs/scripts/soaptest.php(12): SoapClient->SoapClient('https://host...', Array) #1 {main}
0

Please try with this code, hope its work for you...

    <?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require('vendor/zendframework/zend-server/src/Client.php');
require('vendor/zendframework/zend-soap/src/Client.php');
require('vendor/zendframework/zend-soap/src/Client/Common.php');

$wsdlurl = 'https://host/index.php/soap/default?wsdl&services=salesOrderRepositoryV1';

$token = 'dx2x7pl5mxq9hp8jr8efcl5crv2pk699';


$opts = ['http' => ['header' => "Authorization: Bearer ".$token]];
$context = stream_context_create($opts);
//$arguments =
$serviceArgs = array('searchCriteria'=> 
        array('filterGroups' => 
            array ('filters' =>
                array('field' =>'increment_id',
                      'value' => '000000002' , 
                      'condition_type' => 'eq')
                )
         )
);
$soapClient = new \Zend\Soap\Client($wsdlurl);
$soapClient->setSoapVersion(SOAP_1_2);
$soapClient->setStreamContext($context);
$result = $soapClient->salesOrderRepositoryV1GetList($serviceArgs);//array('searchCriteria' => $serviceArgs));
//$result = $soapClient->customerCustomerRepositoryV1GetById(array('customerId' => 1));
/*'search_criteria'=> 
        array('filter_groups' => 
            array ('filters' =>
                array('field' =>'firstname',
                      'value' => 'Veronica' , 
                      'condition_type' => 'eq')
                )
         )
);*/
echo "<pre>"; print_r($result); 
?>
  • same problem here – blob Aug 23 '19 at 10:53
  • i update code, create one custom file in root and add token which we generating from admin. and test it. – Anas Mansuri Aug 23 '19 at 10:57
  • it doesn't work – blob Aug 23 '19 at 11:52

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.