Pierre-Louis Pierre-Louis - 2 months ago 26
PHP Question

PHP (SOAP-ERROR: Parsing WSDL)

I try to make a SOAP request:

$soapclient = new SoapClient('http://www.moviestarplanet.fr/WebService/ThirdParty/ThirdPartyService.asmx?wsdl');
$params = array('username' => 'string', 'password' => 'string');
$response = $soapclient->Login($params);
var_dump($response);


but an error telling me:


Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from
'http://www.moviestarplanet.fr/WebService/ThirdParty/ThirdPartyService.asmx?wsdl'
: failed to load external entity[...]


I searched for a long time on the net, but I haven't found any solution... Anyone can help me, please? Thanks!

Answer

I have found the solution !

<?php
$xml_data = '
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ThirdPartyTokenHeader xmlns="http://moviestarplanet.com/">
      <ThirdPartyToken>8346D304-F85E-4dc1-98EB-033CBEE0217F</ThirdPartyToken>
    </ThirdPartyTokenHeader>
  </soap:Header>
  <soap:Body>
    <Login xmlns="http://moviestarplanet.com/">
      <username>USER</username>
      <password>PASS</password>
    </Login>
  </soap:Body>
</soap:Envelope>
';

$headers = array(
"POST /WebService/ThirdParty/ThirdPartyService.asmx HTTP/1.1",
"Referer: www.moviestarplanet.fr",
"User-Agent: Dalvik/1.6.0 (Linux; U; Android 4.4.2; GT-I9505 Build/KOT49H)",
"Content-Type: text/xml; charset=utf-8",
"Host: www.moviestarplanet.fr",
"Content-length: ".strlen($xml_data),
"Expect: 100-continue"
);

$url = 'http://www.moviestarplanet.fr/WebService/ThirdParty/ThirdPartyService.asmx?WSDL';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data);

$reply = curl_exec($ch); 

echo($reply);
?>
Comments