2

I try to code my PHP Client Soap, that consume ASP.Net webservice, secured with authentication. My php code is :

<?php
ini_set("soap.wsdl_cache_enabled", "0");  
try {
    $client = new SoapClient("https://www.webservicexxx.com:60443/service.asmx?WSDL", array('location' => 'https://webservicexxxcom:60443/service.asmx',
          'login' => "myLogin", 'password' => "myPAssword")); 
} catch (SoapFault $e) {
    echo $e;
}?>

I receive this error message:

 SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://www.webservicexxx.com:60443/service.asmx?WSDL' : failed to load external entity "https://www.webservicexx.com:60443/service.asmx?WSDL" in /var/www/webservice2/soap-client.php:5 Stack trace: #0 /var/www/webservice2/soap-client.php(5): SoapClient->SoapClient('https://www.web...', Array) #1 {main}

knowing that i set enable this extensions on my php.ini on the ubuntu server:

extension = php_openssl.dll
extension = php_soap.dll
extension = php_curl.dll

and when i try to parse another php webservice on the same server with authentication it works :

try { 
    $client = new SoapClient("https://xx.xx.xx.xx:443/webservice1/notificationManager.wsdl", array('location' => 'http://xx.xx.xx.xx./webservice1/soap-server.php',
          'login' => "myLogin", 'password' => "myPass")); 
} catch (SoapFault $exception) { 
    echo $exception;       
} 

Why i can't have response from the first webservice ?

hakre
  • 193,403
  • 52
  • 435
  • 836
Saad Lamarti
  • 300
  • 1
  • 5
  • 15
  • just copy and paste url to the wsdl in your browser to see if you see the wsdl. By doing this ou are sure is not a connectivity problem. – slash28cu Nov 02 '12 at 13:43
  • The wsdl file `https://www.webservicexx.com:60443/service.asmx?WSDL` is accessible via internet browser, and it demand the authentication. – Saad Lamarti Nov 02 '12 at 14:06

2 Answers2

1

I solved this using nusoap.

$params = array(
  "param" => "value"
);

$soap_client = new nusoap_client($wsdl_url, true);
$soap_client->setCredentials(USER_SERVICE, PASS_SERVICE, 'basic');
$soap_client->soap_defencoding = 'UTF-8'; //Fix encode erro, if you need
$soap_return = $soap_client->call("method_name", $params);
Liko
  • 2,130
  • 19
  • 20
0

Why i can't have response from the first webservice ?

Because it failed to load external entity

https://www.webservicexx.com:60443/service.asmx?WSDL

Ensure the WSDL is accessible and reachable by PHP's SoapClient and you should not have the problem any longer.

Edit: According to your comments the WSDL URL requires HTTP Authentication. PHP's SoapClient does support this kind of authentication only with the soap endpoint but not with the WSDL http request. This is why you see the error that it failed. This is related to:

The solution is to request the WSDL file your own and pointing the SoapClient to a copy of it. See the linked question for more information.

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
  • The Webservice `https://www.webservicexx.com:60443/service.asmx?WSDL` is accessible via any navigator, and it demand login and password, to access to the wsdl file. I don't know if i have to configure my server, or contact the vendor of the web-service ?? – Saad Lamarti Nov 02 '12 at 13:20
  • With navigator I guess you mean your internet browser, right? If it demands username and password that means it uses HTTP authentication (*Basic Auth*). Please see [WSDL to PHP with Basic Auth](http://stackoverflow.com/q/10219463/367456) which is probably the next question you have now. – hakre Nov 02 '12 at 13:25
  • I still get an error "failed to load external entity" when using methods of authentication basic, i tried its before. You think that i have to configure something on the ubuntu server ? or i have to contact the vendor of the web-service ? – Saad Lamarti Nov 02 '12 at 13:43
  • I tried to resolve my problem, using this methods: [http://fr2.php.net/manual/en/soapclient.soapclient.php#101503](http://fr2.php.net/manual/en/soapclient.soapclient.php#101503) and [https://bugs.php.net/bug.php?id=27777](https://bugs.php.net/bug.php?id=27777) ! I still have the same problem – Saad Lamarti Nov 02 '12 at 13:54
  • The problem is not with the vendor of the web-service. The problem is that PHP's `SoapClient` is not able to load the WSDL with basic authentication. The problem can be only solved if you save the WSDL to your disk first and then provide it via an WSDL URI that `SoapClient` is able to load. User comment 101503 shows a way how to do that. I could imagine there are other ways how to do that but they are similar to that what has been already outlined so I don't know which information you're missing. – hakre Nov 02 '12 at 14:13