7

I'm trying to consume a SOAP webservice from a distant server, the wsdl file is located here http://ecolinthcm.pi-asp.de/logaserver/services/UsersService?wsdl

I've been in touch with the developers there but they keep telling me that it works fine so they're not of great help...

I'm using this little piece of code to poke the bear see if it's alive :

$WSDL = "http://ecolinthcm.pi-asp.de/logaserver/services/UsersService?wsdl";

// the file_get_contents methods doesn't change the end result unfortunately
//$data = file_get_contents($WSDL);
//file_put_contents('./wsdl.xml',$data);
//$WSDL = './wsdl.xml';

$opts = array(
    'http'=>array(
        'user_agent' => 'PHPSoapClient'
        )
    );

$context = stream_context_create($opts);

$service = new SoapClient($WSDL,array('stream_context' => $context, 'cache_wsdl' => WSDL_CACHE_NONE));
$result = $service->ErmUserBean (array("UserID","Password","TargetUserID"));
print '<pre>';
    var_dump($result);
print '</pre>';

As said in the title I get this message in return :

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find < definitions > in 'WSDL file URI' in C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php:30 Stack trace: #0 C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php(30): SoapClient->SoapClient('WSDL file URI', Array) #1 {main} thrown in C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php on line 30

I've read most post about this errors and therefore tried a lot of variation in my SOAP request. I've also edited my php.ini file so that the line

extension=php_openssl.dll

appears without ";" (comment) before as I could read here.

jpaugh
  • 6,634
  • 4
  • 38
  • 90
Yvann ARGENTIN
  • 73
  • 1
  • 1
  • 3

1 Answers1

5

The error message you get is correct because the WSDL you linked to is invalid. You can download it and feed it to a WSDL validator and you will see it is invalid and fails with a similar validation message.

The WSDL is invalid because certain namespaces are wrong. For example, the namespace for the WSDL schema is not https://schemas.xmlsoap.org/wsdl/ and neither is https://www.w3.org/2001/XMLSchema the namespace for XML schema. The correct ones are with http:// not https://.

miken32
  • 42,008
  • 16
  • 111
  • 154
Bogdan
  • 23,890
  • 3
  • 69
  • 61
  • Note that even if you manage to build a client, the requests to the web service might still fail if more namespaces are wrong, apart those of WSDL and SOAP (i.e. `https://ecolinthcm.pi-asp.de/logaserver/services/UsersService` instead of `http://ecolinthcm.pi-asp.de/logaserver/services/UsersService`) – Bogdan Jun 21 '16 at 19:11
  • I am using wamp in windows, if i try to get category tree my error: https://snag.gy/psFcBi.jpg and my code : https://justpaste.it/6bfrw how can i solve the error? – Gem May 07 '18 at 11:38
  • @Rathinam: what does `http://192.168.1.89/abc/api/v2_soap/?wsdl` return? Open it in a tab of your browser or with cURL from a command prompt console. You might also want to search for that error and see if answers like these ones help in any way: https://stackoverflow.com/questions/21861077/soap-error-parsing-wsdl-couldnt-load-from-but-works-on-wamp – Bogdan May 07 '18 at 13:34
  • @Rathinam: what I see there is that you get an exception. You need to get back a valid WSDL document (an XML) in order for your SOAP client to work. Fix the error in order to get back a proper WSDL. – Bogdan May 10 '18 at 14:23
  • http://192.168.1.89/abc/api/v2_soap?wsdl=1 return : https://snag.gy/VgKvHs.jpg, and api code : https://justpaste.it/6p75t error: https://snag.gy/IO1Ewo.jpg could you pls help me how can solve the error? – Gem May 11 '18 at 05:14
  • @Gem. Technically what you are trying to do here is called Thread hijacking. Only the OP asks questions on SO. Create your own new question and reference this thread in the new one. – Christian Dec 10 '19 at 13:34