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}
Hi @alessandro_tiso ,
Go throught once magento documentation for the SOAP API in magento 2.
https://devdocs.magento.com/guides/v2.3/get-started/soap/soap-web-api-calls.html
I hope it will help you!
Hi I am also new to magento2 I was testing the soap API and facing the same error before then I fixed it like below .
Where the SoapClient is Magento\Framework\Webapi\Soap\ClientFactory
$wsdl = 'http://m2.local.com/soap/?wsdl&services=integrationAdminTokenServiceV1'; $client = $this->soapClient->create($wsdl, array("soap_version" => SOAP_1_2)); $token = $client->integrationAdminTokenServiceV1CreateAdminAccessToken(array("username"=>"tets", "password"=>"tets")); $opts = [ 'ssl' => [ 'verify_peer'=>false, 'verify_peer_name'=>false ], 'http' => [ 'header' => 'Authorization: Bearer '. $token->result ] ]; $params = [ 'stream_context' => stream_context_create($opts), 'cache_wsdl' => WSDL_CACHE_NONE ]; $wsdlUrl = 'http://m2.local.com/soap/default?wsdl&services=quoteCartRepositoryV1'; $soapClient = $this->soapClient->create($wsdlUrl, $params); $soapResponse = $soapClient->__getFunctions(); var_dump($soapResponse);