PHP with XMLRPC and/or SOAP hangs

Hello. I’m trying to access a webservice which supports both XMLRPC and SOAP on https://xxx.xxx.xxx.xxx:8080/, but it always hangs at curl_exec (i think) saying “Error, code 8: CURL error: couldn’t connect to host”.

I’m using PHP 5.2.1 with libcurl/7.15.3 OpenSSL/0.9.7a on a hosted web solution.

I’ve tried both NuSOAP: http://dietrich.ganx4.com/nusoap/
and PHP XMLRPC: http://phpxmlrpc.sourceforge.net/

All examples included in these libraries seem to work, but when I try on my own with:


require_once('nusoaplib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new soapclient('https://xxx.xxx.xxx.xxx:8080/', false,
						$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
	echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$result = $client->call('find_products', array('username','password',userid,'boarding'));
if ($client->fault) {
	echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
} else {
	$err = $client->getError();
	if ($err) {
		echo '<h2>Error</h2><pre>' . $err . '</pre>';
	} else {
		echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
	}
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';

i get the following response:


Error
HTTP Error: cURL ERROR: 7: couldn't connect to host
url: https://xxx.xxx.xxx.xxx:8080/
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0
namelookup_time: 5.1E-05
connect_time: 0
pretransfer_time: 0
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: 0
upload_content_length: 0
starttransfer_time: 0
redirect_time: 0
Request
POST / HTTP/1.0
Host: xxx.xxx.xxx.xxx:8080
User-Agent: NuSOAP/0.7.3 (1.114)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 706

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns2326:find_products xmlns:ns2326="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">username</__numeric_0><__numeric_1 xsi:type="xsd:string">password</__numeric_1><__numeric_2 xsi:type="xsd:int">userid</__numeric_2><__numeric_3 xsi:type="xsd:string">boarding</__numeric_3></ns2326:find_products></SOAP-ENV:Body></SOAP-ENV:Envelope>
Response
Debug
2007-11-28 14:47:27.407258 soapclient: ctor wsdl= timeout=0 response_timeout=30
endpoint=string(28) "https://xxx.xxx.xxx.xxx:8080/"
2007-11-28 14:47:27.407353 soapclient: instantiate SOAP with endpoint at https://xxx.xxx.xxx.xxx:8080/
2007-11-28 14:47:27.407390 soapclient: call: operation=find_products, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=soap
params=array(4) {
  [0]=>
  string(16) "username"
  [1]=>
  string(10) "password"
  [2]=>
  int(userid)
  [3]=>
  string(8) "boarding"
}
headers=bool(false)
2007-11-28 14:47:27.407448 soapclient: serializing param array for operation find_products
2007-11-28 14:47:27.407479 soapclient: in serialize_val: name=0, type=, name_ns=, type_ns=, use=encoded, soapval=
value=string(16) "username"
attributes=bool(false)
2007-11-28 14:47:27.407524 soapclient: serialize_val: serialize string
2007-11-28 14:47:27.407555 soapclient: serialize_val returning <__numeric_0 xsi:type="xsd:string">username</__numeric_0>
2007-11-28 14:47:27.407584 soapclient: in serialize_val: name=1, type=, name_ns=, type_ns=, use=encoded, soapval=
value=string(10) "password"
attributes=bool(false)
2007-11-28 14:47:27.407622 soapclient: serialize_val: serialize string
2007-11-28 14:47:27.407648 soapclient: serialize_val returning <__numeric_1 xsi:type="xsd:string">password</__numeric_1>
2007-11-28 14:47:27.407672 soapclient: in serialize_val: name=2, type=, name_ns=, type_ns=, use=encoded, soapval=
value=int(userid)
attributes=bool(false)
2007-11-28 14:47:27.407703 soapclient: serialize_val: serialize int
2007-11-28 14:47:27.407724 soapclient: serialize_val returning <__numeric_2 xsi:type="xsd:int">userid</__numeric_2>
2007-11-28 14:47:27.407748 soapclient: in serialize_val: name=3, type=, name_ns=, type_ns=, use=encoded, soapval=
value=string(8) "boarding"
attributes=bool(false)
2007-11-28 14:47:27.407780 soapclient: serialize_val: serialize string
2007-11-28 14:47:27.407805 soapclient: serialize_val returning <__numeric_3 xsi:type="xsd:string">boarding</__numeric_3>
2007-11-28 14:47:27.407826 soapclient: wrapping RPC request with encoded method element
2007-11-28 14:47:27.407858 soapclient: In serializeEnvelope length=309 body (max 1000 characters)=<ns2326:find_products xmlns:ns2326="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">username</__numeric_0><__numeric_1 xsi:type="xsd:string">password</__numeric_1><__numeric_2 xsi:type="xsd:int">userid</__numeric_2><__numeric_3 xsi:type="xsd:string">boarding</__numeric_3></ns2326:find_products> style=rpc use=encoded encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2007-11-28 14:47:27.407877 soapclient: headers:
bool(false)
2007-11-28 14:47:27.407904 soapclient: namespaces:
array(0) {
}
2007-11-28 14:47:27.407946 soapclient: endpoint=https://xxx.xxx.xxx.xxx:8080/, soapAction=, namespace=http://tempuri.org, style=rpc, use=encoded, encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2007-11-28 14:47:27.407970 soapclient: SOAP message length=706 contents (max 1000 bytes)=<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns2326:find_products xmlns:ns2326="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">username</__numeric_0><__numeric_1 xsi:type="xsd:string">password</__numeric_1><__numeric_2 xsi:type="xsd:int">userid</__numeric_2><__numeric_3 xsi:type="xsd:string">boarding</__numeric_3></ns2326:find_products></SOAP-ENV:Body></SOAP-ENV:Envelope>
2007-11-28 14:47:27.408008 soapclient: transporting via HTTP
2007-11-28 14:47:27.408322 soapclient: sending message, length=706
2007-11-28 14:47:27.408068 soap_transport_http: ctor url=https://xxx.xxx.xxx.xxx:8080/ use_curl= curl_options:
array(0) {
}
2007-11-28 14:47:27.408112 soap_transport_http: parsed URL scheme = https
2007-11-28 14:47:27.408134 soap_transport_http: parsed URL host = xxx.xxx.xxx.xxx
2007-11-28 14:47:27.408154 soap_transport_http: parsed URL port = 8080
2007-11-28 14:47:27.408173 soap_transport_http: parsed URL path = /
2007-11-28 14:47:27.408201 soap_transport_http: set header Host: xxx.xxx.xxx.xxx:8080
2007-11-28 14:47:27.408246 soap_transport_http: set header User-Agent: NuSOAP/0.7.3 (1.114)
2007-11-28 14:47:27.408277 soap_transport_http: set header Content-Type: text/xml; charset=ISO-8859-1
2007-11-28 14:47:27.408299 soap_transport_http: set header SOAPAction: ""
2007-11-28 14:47:27.408360 soap_transport_http: entered send() with data of length: 706
2007-11-28 14:47:27.408387 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme https, host xxx.xxx.xxx.xxx, port 8080
2007-11-28 14:47:27.408421 soap_transport_http: connect using cURL
2007-11-28 14:47:27.408480 soap_transport_http: setCurlOption option=10002, value=
string(28) "https://xxx.xxx.xxx.xxx:8080/"
2007-11-28 14:47:27.408515 soap_transport_http: safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION
2007-11-28 14:47:27.408534 soap_transport_http: safe_mode = 
string(1) "1"
2007-11-28 14:47:27.408557 soap_transport_http: open_basedir = 
string(49) "/home/sjumil:/usr/lib/php:/usr/local/lib/php:/tmp"
2007-11-28 14:47:27.408583 soap_transport_http: setCurlOption option=42, value=
int(1)
2007-11-28 14:47:27.408609 soap_transport_http: setCurlOption option=19913, value=
int(1)
2007-11-28 14:47:27.408636 soap_transport_http: setCurlOption option=13, value=
int(30)
2007-11-28 14:47:27.408660 soap_transport_http: set cURL SSL verify options
2007-11-28 14:47:27.408679 soap_transport_http: setCurlOption option=64, value=
int(0)
2007-11-28 14:47:27.408705 soap_transport_http: setCurlOption option=81, value=
int(0)
2007-11-28 14:47:27.408731 soap_transport_http: cURL connection set up
2007-11-28 14:47:27.408761 soap_transport_http: set header Content-Length: 706
2007-11-28 14:47:27.408782 soap_transport_http: HTTP request: POST / HTTP/1.0
2007-11-28 14:47:27.408803 soap_transport_http: HTTP header: Host: xxx.xxx.xxx.xxx:8080
2007-11-28 14:47:27.408822 soap_transport_http: HTTP header: User-Agent: NuSOAP/0.7.3 (1.114)
2007-11-28 14:47:27.408841 soap_transport_http: HTTP header: Content-Type: text/xml; charset=ISO-8859-1
2007-11-28 14:47:27.408860 soap_transport_http: HTTP header: SOAPAction: ""
2007-11-28 14:47:27.408879 soap_transport_http: HTTP header: Content-Length: 706
2007-11-28 14:47:27.408906 soap_transport_http: Skip cURL header Host: xxx.xxx.xxx.xxx:8080
2007-11-28 14:47:27.408931 soap_transport_http: Skip cURL header Content-Length: 706
2007-11-28 14:47:27.408952 soap_transport_http: setCurlOption option=10023, value=
array(3) {
  [0]=>
  string(32) "User-Agent: NuSOAP/0.7.3 (1.114)"
  [1]=>
  string(42) "Content-Type: text/xml; charset=ISO-8859-1"
  [2]=>
  string(14) "SOAPAction: """
}
2007-11-28 14:47:27.408985 soap_transport_http: set cURL HTTP headers
2007-11-28 14:47:27.409006 soap_transport_http: setCurlOption option=47, value=
int(1)
2007-11-28 14:47:27.409032 soap_transport_http: setCurlOption option=10015, value=
string(706) "<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns2326:find_products xmlns:ns2326="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">username</__numeric_0><__numeric_1 xsi:type="xsd:string">password</__numeric_1><__numeric_2 xsi:type="xsd:int">userid</__numeric_2><__numeric_3 xsi:type="xsd:string">boarding</__numeric_3></ns2326:find_products></SOAP-ENV:Body></SOAP-ENV:Envelope>"
2007-11-28 14:47:27.409120 soap_transport_http: set cURL POST data
2007-11-28 14:47:27.409140 soap_transport_http: set cURL payload
2007-11-28 14:47:27.409163 soap_transport_http: send and receive with cURL
2007-11-28 14:47:57.406829 soap_transport_http: cURL ERROR: 7: couldn't connect to host<br>url: https://xxx.xxx.xxx.xxx:8080/<br>http_code: 0<br>header_size: 0<br>request_size: 0<br>filetime: -1<br>ssl_verify_result: 0<br>redirect_count: 0<br>total_time: 0<br>namelookup_time: 5.1E-05<br>connect_time: 0<br>pretransfer_time: 0<br>size_upload: 0<br>size_download: 0<br>speed_download: 0<br>speed_upload: 0<br>download_content_length: 0<br>upload_content_length: 0<br>starttransfer_time: 0<br>redirect_time: 0<br>
2007-11-28 14:47:57.406912 soap_transport_http: end of send()
2007-11-28 14:47:57.406973 soapclient: Error: HTTP Error: cURL ERROR: 7: couldn't connect to host<br>url: https://xxx.xxx.xxx.xxx:8080/<br>http_code: 0<br>header_size: 0<br>request_size: 0<br>filetime: -1<br>ssl_verify_result: 0<br>redirect_count: 0<br>total_time: 0<br>namelookup_time: 5.1E-05<br>connect_time: 0<br>pretransfer_time: 0<br>size_upload: 0<br>size_download: 0<br>speed_download: 0<br>speed_upload: 0<br>download_content_length: 0<br>upload_content_length: 0<br>starttransfer_time: 0<br>redirect_time: 0<br>

it seems like the webservice dosn’t exists to PHP? But the webservice provider claims the service is up and running at https://xxx.xxx.xxx.xxx:8080/ (which actually gives a response when entered directly in the browser, it’s just PHP/CURL who don’t seem to find it?)

Any idea what the problem could be? And what does the proxy parameters mean? Is this anything I need to fill out?

Any help greatly appreciated!:slight_smile:

do the contents appear when you try to file_get_contents(“https://xxx.xxx.xxx.xxx:8080/”) on the site?

If not, then it may be that the site doesn’t allow web programs to view it.

Hm, hard to tell:

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration…

Ah, you need to enable ‘allow_url_fopen’ in php.ini

Yes, but I can’t since I’m on a shared host… But the https request itself in NuSOAP goes via CURL as far as I can tell? So enabling allow_url_fopen wouldn’t solve the actual problem?

It seems like the connection is blocked by server’s firewall; which is likely on a shared host?

That seems possible. I’ll contact my hosting provider to confirm this.

Host confirmed that connection was blocked in firewall, and opened 8080 which solved the problem :slight_smile:

For XML-RPC you can use the xmlrpc library from the crVCL Framework, it is easy to use and work also fast for a high number of requests.

See: http://www.cr-solutions.net/p/projects