I am having serious trouble trying to get this url to load in my code. When I go to the actual page in the browser it loads fine, but when I parse it its basically giving a 404, I have tried this using soap client and curl thinking ok maybe im doing something wrong.
This is my code, you can see its the bare basics.
$customerId = 'xxxx';
$authenticationId = 'xxxx';
$url = 'https://test.api.800loanmart.com/LoanmartService.svc?wsdl';
$config = array('trace' => 1, 'exceptions' => 0);
$service = new SoapClient($url,$config);
$result = $service->GetTermsAndConditions($customerId, $authenticationId);
var_dump($service);
and this is what it is throwing back at me...
Warning: SoapClient::SoapClient() [soapclient.soapclient]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in C:\xampp\htdocs\loanmart\index.php on line 6
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "https://test.api.800loanmart.com/LoanmartService.svc?wsdl" in C:\xampp\htdocs\loanmart\index.php on line 6
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://test.api.800loanmart.com/LoanmartService.svc?wsdl' : failed to load external entity "https://test.api.800loanmart.com/LoanmartService.svc?wsdl" in C:\xampp\htdocs\loanmart\index.php on line 6
I have checked to see if I have openssl and it is turned on in my php.ini file, im just pretty stumped as to what to do.
Simple issue that gave me headaches! Open your php.ini file in your apache server directory and uncomment(enable) the line extension=php_openssl.dll.
This fix my issue.
Even if you did check, this is nothing but an openssl configuration issue (used in SoapClient, but still)
Try to file_get_contents($wsdl_url);
Also, check your currently loaded php.ini & supported streams (php.ini might differs from CLI to web SAPI)
php -r "phpinfo();" > file.txt
Mine :
Registered PHP Streams => php, file, glob, data, http, ftp, zip, compress.zlib, compress.bzip2, https, ftps, phar
Registered Stream Socket Transports => tcp, udp, ssl, sslv3, sslv2, tls
(your code sample works on my computer :p)
make active extension=php_openssl.dll in php.ini. Restart server.
Related
While consuming the webservice, I sometimes get this error. And they are pretty sure their webservice is up and running.
Our server is amazon ec2 and php version is : PHP 5.3.20
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://...webservice..asmx?wsdl' : failed to load external entity "http://...webservice..asmx?wsdl"
Any idea?
You can Try enabling the php_openssl extension in your local server by only uncommening the line "extension=php_openssl.dll" in you php.ini file
I'm running a php site on localhost and i'm getting the following error.
Warning: file_get_contents(http://www.engadget.com/rss.xml)
[function.file-get-contents]: failed to open stream: HTTP request
failed! in C:\Program Files\xampp\htdocs\infohut\rss_read_class.php on
line 26
but when i run the same hosted in a real server, it doesn't give any error.
Also note that my local pc is connecting through a proxy and when i tried from a different pc with a direct connection to internet, the problem is not there.
So my guess is it has something to do with the proxy.
I'm using xampp for windows installation with php 5.1.4 and Apache 2.2.2
I tried adding my proxy settings to php.ini as well using below
pfpro.proxyaddress
pfpro.proxyport
still couldn't figure is out. Please advise if i need to change any other settings or anything.
Thanks
You should enable allow_url_fopen in your php.ini
A little while ago I noticed some Soap errors emitting from my app and I started to investigate them. Stuff like:
SoapClient::SoapClient(http://###.###.###.###:8080/path/to/some.wsdl): failed to open stream: HTTP request failed!
SoapClient::SoapClient(): I/O warning : failed to load external entity "http://###.###.###.###:8080/path/to/some.wsdl"
SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://###.###.###.###:8080/path/to/some.wsdl' : failed to load external entity "http://###.###.###.###:8080/path/to/some.wsdl"
It looked like a timeout on the remote server (WSDL caching was turned off). After bouncing that server and having no luck, I tried to just file_get-contents() the WSDL to see what would happen...
No dice: After about 20 seconds or so I got the same stream error:
file_get_contents(http://###.###.###.###:8080/path/to/some.wsdl) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed!
In a last ditch effort, I tried to read the contents via the curl_* functions, and I do in fact get what I'm looking for.
... tl;dr?
SoapClient and file_get_contents appear to be timing out (though not an explicit "Failed to open stream, connection timed out")
It appears to be related to streams since curl gives me what I'm looking for.
I've got a lot of code that depends on SoapClient and file_get_contents so switching to an all curl solution isn't really an option.
This is not a DNS issue as I can resolve external names fine (and my target resource is an IP)
allow_url_fopen is enabled.
Any ideas?
allow_url_fopen needs to be On in your PHP settings for file_get_contents to work with URLs. It'll give you that exact error otherwise. Double-check your PHP settings by loading a page with a phpinfo(); call to make sure they're not being overridden by a different php.ini or .htaccess file.
I'd guess a firewall problem otherwise but you say curl works from inside PHP, which would be opening sockets in the same manner.
I am using file_get_contents on my PHP and it throws some errors:
My code
#try to fetch from remote
$this->remotePath = "http://some-hostname.com/blah/blah.xml
$fileIn = #file_get_contents($this->remotePath);
The errors:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /virtual/path/to/file/outputFile.php on line 127
Warning: file_get_contents(https://some-host-name/data/inputFile.xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /virtual/path/to/file/outputFile.php on line 127
Any idea? It worked fine in my computer but stopped working when I ported it to the web server.
Your server must have the allow_url_fopen property set to true. Being on a free webhost explains it, as it's usually disabled to prevent abuse. If you paid for your hosting, get in contact with your host so they can enable it for you.
If changing that setting is not an option, then have a look at the cURL library.
It seems "allow_url_fopen" setting is false on your server and hence does not allow using URLs with file_get_contents().
Try using CURL instead that is a better and efficient way of communicating with other server.
I used the following code to load the xml for further process, while load itself it display the following warning in the client server but its working fine in my local machine.
Code:
$xmlDoc = new DOMDocument();
$xmlDoc->load('http://www.domainname.com/xmlfilename');
Warning: DOMDocument::load(http://www.domainname.com/xmlfilename)
[domdocument.load]: failed to open stream: Connection timed out
Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed
to load external entity "http://www.domainname.com/xmlfilename"
Increase the time until Connection Timeout before calling load:
libxml_set_streams_context(
stream_context_create(
array('http' => array('timeout' => 120))
)
);
or
ini_set('default_socket_timeout', 120);
See
libxml_set_streams_context — Set the streams context for the next libxml document load or write
HTTP Context Options
Ini Setting: default_socket_timeout
First, make sure your client's server is configured with allow_url_fopen set to true.
I'd also be checking firewall rules on the server. Perhaps it's not allowed to make HTTP requests.