Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in

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.

like image 843
Yvann ARGENTIN Avatar asked Jun 16 '16 09:06

Yvann ARGENTIN


People also ask

Why is my SOAP server unable to load WSDL?

This means that if your Magento store is not accessible from the the server itself, SOAP server will not be able to load WSDL during initialisation. As a result you encounter this error. To verify if it is possible to connect to the Magento API, you can use curl: SITE="example.com"curl -v https://$SITE/index.php/api/index/index/wsdl/1/

Why can’t I connect to the SOAP API from Hypernode?

Magento’s SOAP API references its own WSDL, making the magento instance depend on its own api endpoint. If it is not possible to connect to the SOAP API from the Hypernode, you will get this error when trying to perform requests.

Why is my WSDL file in/tmp/not working?

In some cases the WSDL cache file in /tmp/ is corrupted, causing the same error. If you run into this issue, use the following workaround to recache your WSDL file:

Why is my SSL certificate not showing up in soapclient?

If you use docker and php 7.4 (my case) you probably get error because default security level in OpenSSL it too high for wsdl cert. Even if you disable verify and allow self-signed in SoapClient options. You need lower seclevel in /etc/ssl/openssl.cnf from DEFAULT@SECLEVEL=2 to Show activity on this post.


1 Answers

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 (e.g. https://www.wsdl-analyzer.com/) 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://.

I fixed the namespaces and uploaded a valid WSDL file here: http://filebin.ca/2lByBlPAOvCu/ChangedUsersService.xml. You can compare it with the original file which I saved here: http://filebin.ca/2lBxfIDsyDas/OriginalUsersService.xml and see the differences.

Try using my WSDL file. Feed it to the online validator and to your code and see if it works.

like image 190
Bogdan Avatar answered Sep 29 '22 23:09

Bogdan