I'm trying to integrate a PHP portal with a CRM(microsoft dynamics .NET) system using SOAP.
This is part of my code:
$client = new SoapClient("http://XX.XXX.X.XX:5050/host.svc?wsdl");
This line returns 2 errors
Warninig: Message: SoapClient::SoapClient(http://80.248.5.35:5050/host.svc?wsdl): failed to open stream: Connection refused
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://XX.XXX.X.XX:5050/host.svc?wsdl' : failed to load external entity
Opening the link in the browser works and running this code in my local machine(localhost) works also.
i've tried file_get_contents("http://XX.XXX.X.XX:5050/host.svc?wsdl"); but this returns a warning message
Message: file_get_contents(http://80.248.5.35:5050/host.svc?wsdl): failed to open stream: Connection refused
i've tried so many solutions from stackoverflow.
If anyone could help me with this or shed more light on the situation cause this is my first attempt at something like this. Thanks
I found out the problem.
My webserver was denying me from making outgoing connection through any port rather than the default port. i fixed it by changing the web service to the default port on the ISS
I've been frustrated by this "failed to open stream" error too, but from the point of view of trying to connect to a web service from the web.
However, the issue is the same underneath: your web server needs to be able to reach the web service from itself.
My solution if you are using a Windows Server: add an entry to your windows host file to allow loopback on the server for the external domain you're using for the web service.
So, open your "hosts" file, which is usually in somewhere like C:\Windows\System32\drivers\etc. Then add a line like:
<machine LAN IP like 192.168.1.1 or 127.0.0.1> <domain.ofwebsevice.com>
Related
When I connect to the network using the local network connection I am unable to establish a connection to my server. It returns the following error:
Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xxxx\htdocs\xxxx.xxxx\class\class.mysql.php on line 11
Connect Error (2002) A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Warning: mysqli::close(): Couldn't fetch mysql in C:\xxxx\htdocs\xxxx.xxxx\class\class.mysql.php on line 59
Now when I tether through my phone I have no problems connecting to the server.
My knowledge of networking is extremely ignorant so do forgive me if this is obvious, but what could some of the issues be stopping my connection to the server?
I have figured out the answer to the problem I was experiencing. I am documenting below, just in case it helps anyone else.
=========================
I recently came across a problem when working through the 4th edition of Kevin Yank's "Build Your Own Data-Driven Website."
There appears to be an incompatibility between certain software packages and operating systems. In particular, this affects PHP 5.3 when trying to connect to MySQL while running on Windows Vista with Apache. It is not really a bug, but a discrepancy between how far along the different elements are in the transition from IPv4 to IPv6.
Basically, when PHP tries to connect to the database, it times out because it does not recognize localhost, only 127.0.0.1, and produces the following error message:
=========================
Warning: mysqli_connect() [function.mysqli-connect]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2
Fatal error: Maximum execution time of 30 seconds exceeded in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\phpmysql-4\chapter4\connect\index.php on line 2
=========================
There are two possible solutions to this problem:
=========================
Replace "localhost" with "127.0.0.1" in all PHP files that you wish to have connect to a MySQL database
Locate the "hosts" file on your computer. It is typically at a location such as this:
C:\Windows\System32\drivers\etc\hosts
Open it up, and comment out the line that prevents the localhost from "mapping" correctly; in otherwords, change
::1 localhost
to
::1 localhost
This solution was, in fact, presented in the SitePoint forums previously, though without a full explanation of the details.
http://www.sitepoint.com/forums/showthread.php?t=637612
=========================
The issue is described in detail on the PHP forum at the following link:
http://bugs.php.net/bug.php?id=45150
Please note that -- from what I understand -- Windows XP does not have this problem, as it is configured only to IPv4. Vista runs into a problem because it is designed to handle both, as is Windows 7.
Also, I should mention that using PHP 5.2 with the aforementioned book is not recommended because there is a bug in that version -- a veritable one -- that causes Apache to crash when it attempts to open the "deletejoke" file.
I'm getting the following error message in a php-file when trying to connect to a third party server.
HTTP Error: Couldn't open socket connection to server http:// xxxxxxxx prior to connect(). This is often a problem looking up the
host name.
I know that the address is correct. What is the most common problem with this error? Could it be that the server only accept certain IP's to connect?
I have installation of magento 1.6.1 on local machine i\’m trying to connect magetno\’s api in php using following code
$proxy = new SoapClient('http://localhost/magento/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiuser', 'apikey');
I can connect using this code if internet connection on, If I make it off it doesn't work.
it gives following errors
Warning: SoapClient::SoapClient() [soapclient.soapclient]: php_network_getaddresses: getaddrinfo failed: No such host is known. in E:\wamp\www\magentomanager\api\products.php on line 12
Warning: SoapClient::SoapClient(http://schemas.xmlsoap.org/soap/encoding/) [soapclient.soapclient]: failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in E:\wamp\www\magentomanager\api\products.php on line 12
please let me know what is the reason behind that?.
why magento needed internet connection for accessing local api. how do I access api without having without internet connection?
Magento's API is based on SOAP, as you may have found out. SOAP is based on XML and uses therefor schema files, which desribes the schema/layout for the SOAP calls for this service. So this file might be loaded before/on every SOAP call.
However, a workaorund could be to store the schema description on your local machine and editing Magento's wsdl.xml files, so that they will reference to your local machine. Simply search for the URL in all xml files inside your Magento installation.
Not a very nice workaround, but hey,... it's a workaround.
I think the problem is that localhost can't be resolved to your local IP or 127.0.0.1. You can add it in your host file or call it thru http:/// instead of http://localhost
I recently downloaded and installed "PHP for Android." I created a .php file that utilizes an SSL connection with port 2195. I followed a guide for writing a php server that sends push notifications to Apple's APNS, and SUCCESSfully ran it on my Mac. When I put both the .php and the .pem onto my Android phone in the same folder and tried to run it with the same WIFI connection, I get the following error message:
Error:14094410:SSL routines:func(148):reason(1040) in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Warning: stream_socket_client(): Failed to enable crypto in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /mnt/sdcard/sl4a/scripts/lot.php on line 19
Does anyone have any ideas of how I can fix this?
THANKS!
I had the SSL error on my Windows desktop, with a PHP script that accessed a HTTPS resource.
The solution was to enable the openssl extension. So maybe it's the same kind of problem you have here, something related to opensll on Php for Android.
I'm not sure how to fix it, but Google has it's own push notification framework. There is an example here: http://code.google.com/android/c2dm/
Edit to Answer:
I think that most likely the problem has to do with the certificates needed to make the call over SSL. It is possible that the PHP for Android app does not have permissions to access security certificates you need.
My project uses PHP JavaBridge, I have installed WAMP, JRE 6.0, and Tomcat 6.0.32
I can now access http://localhost:8080/ successfully but when I run my PHP site it gives me the following error
warning: fsockopen() [function.fsockopen]: unable to connect to localhost:8080 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. )
Can anyone please help me with this issue?
EDIT
Forgot to mention that I am using Windows 7
My comment above worked as a solution and hence this answer, so that in future others get it.
Can you 127.0.0.1:8080 instead of localhost:8080? See what do you get?
fsocketopen takes the hostname and it should be a valid domain, in your case, (in general) it could be a valid domain as long as you have an entry for localhost in your hosts file (C:\Windows\System 32\drivers\etc\hosts). See if you have something similar to that.