Solved

PHP with XMLRPC/SOAP hangs

Posted on 2007-11-28
5
743 Views
Last Modified: 2013-11-18
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 the attached code snippet I get the response posted at the end of this post.

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 answer when the URL 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?

Response from NuSOAP when running attached code snippet:
--------------------------------------------------------------------------
HTTP Error: cURL ERROR: 7: couldn't connect to host
url: [url]https://xxx.xxx.xxx.xxx:8080/[/url]
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 [url]https://xxx.xxx.xxx.xxx:8080/[/url]
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>
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>';

Open in new window

0
Comment
Question by:madman2k
  • 2
5 Comments
 
LVL 4

Expert Comment

by:simonkin
Comment Utility
Hi,

Sounds like you need to enable "allow_url_fopen" in your php.ini file.

If you are on a shared host I doubt your hosting provider has this enabled as it is a security vulnerability.

If you have your own host and you allow this setting please take precautions...
0
 

Author Comment

by:madman2k
Comment Utility
Yes, allow_url_fopen is turned off and I can't enable it since I'm on a shared host. But as far as I can tell, https requests via NuSOAP goes via CURL (and not allow_url_fopen?))
0
 

Accepted Solution

by:
madman2k earned 0 total points
Comment Utility
Problem solved! Since I'm on a shared host, the hosting provider's firewall blocked my secure CURL connection. I got in touch with customer support who opened port 8080 and solved the problem.
0
 
LVL 1

Expert Comment

by:Vee_Mod
Comment Utility
Closed, 500 points refunded.
Vee_Mod
Community Support Moderator
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now