When I try to use SoapClient:
try {
$client = new SoapClient('http://someurl/somefile.wsdl');
} catch (SoapFault $e) {
var_dump($e);
}
I have catch error with:
["faultstring"] => "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://someurl/somefile.wsdl' : failed to load external entity "http://someurl/somefile.wsdl"
["faultcode"] => "WSDL"
I can manually download http://someurl/somefile.wsdl and can file_get_contents for this file. I try to use it before on different computer and it worked. Possible problem with php or apache settings..
ArchLinux with last updates for php and apache. I tried to enable all php extensions.
Were you able to get wsdl using file_get_contents() in browser?
I had similar issue recently in Archlinux with same faultstring, no matter what wsdl file was used. The same code was working without any problem on other Archlinux machine and Windows XP box.
After some research, it came out that problem arose only when I tried to access the page in browser - script accessed from command line worked as expected. Then I changed the script to download the wsdl file directly, using aforementioned file_get_contents() - it gave me a warning "php_network_getaddresses: getaddrinfo failed: Name or service not known".
Few tutorials (on SO, or this one: http://albertech.net/2011/05/fix-php_network_getaddresses-getaddrinfo-failed-name-or-service-not-known/ ) later I haven't fought off the problem yet. But then I discovered what introduced the issues: I had been running NetworkManager since the installation of Arch (to better handle wireless), and few weeks later I've added mysqld and httpd as last to DAEMONS section in rc.conf - it seems this broke DNS resolution for apache.
Having two solutions (go back to starting servers manually or try other network manager) I've switched to wicd and haven't run into the issue again.
Related
Server is CENTOS with PHP 5.4 and Apache 2.2.
I have a SoapClient object like this:
$client = new \SoapClient(__DIR__ . "/wsdlfilehere.wsdl", array("soap_version"=>SOAP_1_2, "trace"=>true));
After awhile (within 24 hours), this code throws an error:
SOAP-ERROR: Parsing WSDL: Couldn't load from '/wsdlfilehere.wsdl' : failed to load external entity "/wsdlfilehere.wsdl".
Then after I restart apache and it works again.
Edit: even setting cache_wsdl to WSDL_CACHE_NONE doesn't fix the issue.
After digging around I finally found a workaround/solution.
Following this link on Ubuntu's launchpad it seems that other people are also experiencing this problem. I followed zabuch's instruction at comment #6 and it seems to work now. I agree with him that the issue might be on mod_php/php itself and not Ubuntu only, since I'm on CentOS and have experienced this problem.
From zabuch's comment:
The workaround for the issue is to add this:
libxml_disable_entity_loader(false);
before creating new SoapClient.
I have installed AMPPS on OS X Mavericks and I am getting the error below when I try to access a WSDL over HTTPS in PHP by using the SoapClient class.
SOAP-ERROR: Parsing WSDL: Couldn't load from
'https://www.some-domain.com/Webservice.asmx?WSDL' : failed to load
external entity
"https://www.some-domain.com/secure/api/Webservice.asmx?WSDL"
OpenSSL, SOAP and cURL is enabled in when I run phpinfo(). I can retrieve the WSDL contents just fine by using file_get_contents(). There is no firewall blocking the connection. Other computers on the same network can connect just fine. Below is my code. It works on the production server as well as several other computers that I have used it on.
$this->wsdlUrl = 'https://www.some-domain.com/Webservice.asmx?WSDL';
$this->client = new SoapClient($this->wsdlUrl);
$this->client->Connect(array(
/* Login credentials */
));
I have also tried to use a stream context with verify_peer set to false, but with the same result. Increasing the default_socket_timeout option also does not work as some people have suggested.
I understand that there are several other questions concerning this error, but none of the proposed solutions that I could find work for me.
Any ideas? Thanks in advance!
I'm sure this will point you to the right direction:
try {
$sc= new SoapClient('https://www.some-domain.com/Webservice.asmx?WSDL');
$sc->Connect(/* Login credentials */);
} catch (SoapFault $fault) {
print_r($fault->faultstring);
}
I am trying to create tasks using gearman using GearmanClient class from the gearman-php-extensions. I am able to run below program using command prompt-
//php client.php works fine
<?php
$client= new GearmanClient();
$client->addServer();
$task = $client->do("send", "hi");
?>
But I wan't to run this code in some yii controller. It seems like yii is not able to find the path upto GearmanClient class, but why?
Also I am writing the yii programs in eclipse. As php command and eclipse are both using the same php library, my yii controller should work fine. Instead my browser gives errors like-
PHP warning
include(GearmanClient.php): failed to open stream: No such file or directory
#plus some warnings and the yii stack trace.
This is happening because, the process that is handling the php files is not updated with the latest php.ini configuration. So you just need to restart that process.
Therefore:
If php handler is running as a web server module, then you'll need to restart the web server.
If you have php running as a cgi process, then you'll need to restart that process.
I have an issue with obtaining data from Windows Azure's runtime using the newest (at the time of writing) PHP SDK from Github. Here is a test I am running on one of our hosted services:
<?php
include 'WindowsAzure/WindowsAzure.php';
use \WindowsAzure\ServiceRuntime\RoleEnvironment;
use \WindowsAzure\ServiceRuntime\Internal\RoleEnvironmentNotAvailableException;
try {
echo RoleEnvironment::getDeploymentId();
}
catch (RoleEnvironmentNotAvailableException $Exception) {
die('Failed to find deployment id');
}
RoleEnvironmentNotAvailableException is always thrown. Looking at the source, it seems to try sending commands through a named pipe (\.\pipe\WindowsAzureRuntime). Do I need to specify something within my ServiceConfiguration.csdef/cscfg in order to have access to this named pipe?
Any advice would be most welcome!
Got confirmation from MS EMEA Developer Support that current SDK does not support this function. They suggested similar workaround to jonnu above - use the previous SDK's functionality for role environment / configuration settings.
The ServiceRuntime APIs run only on Cloud so if this code snippet runs on local machine it'll throw an exception as you've pointed out. Further, if you want to debug your ServiceRuntime code you've to deploy your service to WA then use remote desktop connection to access the cloud machine and debug your code.
This question relates to the requirement to utilize a WCF service hosted in a Windows application on Windows 2008 Server, from PHP scripts which are hosted in IIS 7 on the same server, and from other applications hosted elsewhere.
The application has been developed and tested thoroughly on a Windows 7 machine using Visual Studio 2010, .NET Framework 4, IIS 7, and various versions of PHP.
On the Windows 7 machine, netsh was used as follows.
netsh http add urlacl url=http://localhost:8000/WCFService/ user=machinename\user
Various other ports were also successfully added and used during testing.
When the application was copied to the Windows 2008 Server, the essential parts of the application were successfully tested.
The same netsh command was used on Windows 2008 Server, yet localhost was replaced with the server IP and machinename with domain as follows:
netsh http add urlacl url=http://serveripaddress:8000/WCFService/ user=domain\user
During attempts to get the PHP SoapClient working, various user="..." options were attempted, including "everyone".
The initial PHP SoapClient script is as follows:
try {
$client = new SoapClient("http://serveripaddress:8000/WCFService/?wsdl");
} catch (Exception $e) {
echo $e->getMessage(), "\n";
exit();
}
During initial testing, the following errors were encountered:
Warning:
SoapClient::SoapClient(http://serveripaddress:8000/WCFService/?wsdl)
[soapclient.soapclient]: failed to open stream: HTTP request failed!
in C:\inetpub\wwwroot\Sites\www.myurl.com\WCF-Test.php on line 7
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O
warning : failed to load external entity
"http://serveripaddress:8000/WCFService/?wsdl" in
C:\inetpub\wwwroot\Sites\www.myurl.com\WCF-Test.php on line 7
SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://serveripaddress:8000/WCFService/?wsdl' : failed to load
external entity "http://serveripaddress:8000/WCFService/?wsdl"
After some fiddling around the error reduced to the following:
SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://serveripaddress:8000/WCFService/?wsdl' : failed to load
external entity "http://serveripaddress:8000/WCFService/?wsdl"
I then extracted the wsdl into a file and used the following PHP script:
try {
$client = new SoapClient("wsdl\wcf-wsdl.wsdl");
} catch (Exception $e) {
echo $e->getMessage(), "\n";
exit();
}
The error then changed slightly to the following:
SOAP-ERROR: Parsing Schema: can't import schema from
'http://serveripaddress:8000/WCFService/?xsd=xsd0'
I am of the opinion that the issue at hand relates to the "visibility" of the service, to the client, and possibly permissions.
After reading dozens of posts, I still have not been able to find a solution to this issue.
Any assistance will be greatly appreciated.
Many thanks in advance.
If the WCF Service is something you are hosting for it to be accessed by php clients you need to have a flat wsdl. On how to generate Flat Wsdl follow the below link:
How to flatten your wsdl
The same feature would be avaiable in the framework as part of .NET 4.5. Hope that helps you out.
If you know you are working with a .NET WCF service you can just change the location you download the wsdl from .svc?wsdl to .svc?singleWsdl and the WCF server will take care of the recursion / linking work for you.
This may the answer,.net has the default config make this error.
https://bugs.php.net/bug.php?id=47761