hey all
I’m dabbling with web services and just cannot get anything to work. I have check with PHPinfo and soap is installed.
This script is in the same folder as the nusoap files but I just cannot get anything to return a response.
<?php
// Pull in the NuSOAP code
require_once('nusoap.php');
// Create the client instance
$client = new soapclient('http://www.mickthetree.com/soapTest/nusoapintro/helloworld2.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Constructor error: ' . $err . '</b></p>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$result = $client->call('hello', array('name' => 'Scott'));
// Check for a fault
if ($client->fault) {
echo '<p><b>Fault: ';
print_r($result);
echo '</b></p>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>';
} else {
// Display the result
print_r($result);
}
}
// Display the request and response
echo '<h2>Request</h2>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
// Display the debug messages
echo '<h2>Debug</h2>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
When I run the client script
http://mickthetree.com/soapTest/nusoap/lib/helloworld2client.php
I get a blank page returned.
apart from the urls nothing in this script is changed from the many sites that have this listed (including the guy who wrote nusoap http://www.scottnichol.com/soap/index.html)
Error logs show the following:
“PHP Warning: SoapClient::SoapClient(http://www.mickthetree.com/soapTest/nusoapintro/helloworld2.php) [<a href=‘soapclient.soapclient’>soapclient.soapclient</a>]: failed to open stream: Connection refused in /home/sites/mickthetree.com/public_html/soapTest/nusoap/lib/helloworld2client.php on line 5”
"HP Warning: SoapClient::SoapClient() [<a href=‘soapclient.soapclient’>soapclient.soapclient</a>]: I/O warning : failed to load external entity "http://www.mickthetree.com/soapTest/nusoapintro/helloworld2.php" in "
Can anyone help me to understand what is going wrong here?
Kind regards
The “blank page” is returning an HTTP Internal Server error header.
My guess would be the WSDL file is buggy. Though it could be a naming conflict with PHP5’s native soapclient class - or something else 
Is helloworld2client.php line 5
$client = new soapclient('http://www.mickthetree.com/soapTest/nusoapintro/helloworld2.php');
but you’re not getting a Constructor error $err message?
thanks for taking a look for me.
I found this same script on numerous sites including the guy who wrote nusoap so I assume the script is fine. 
Would you have a simple WSDL client and server script you know works that I could try out on my servers?
I’m trying to check with something simple first as I have a bigger project that I cannot get to work either and I want to make sure its not my servers causing the problems with the scripts.
I have a few. These that use the native PHP SOAP are from an O’Reilly tutorial http://www.onlamp.com/pub/a/php/2007/07/26/php-web-services.html
catalog.wsdl
<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='Catalog'
targetNamespace='http://example.org/catalog'
xmlns:tns='http://example.org/catalog'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
<message name='getCatalogRequest'>
<part name='catalogId' type='xsd:string'/>
</message>
<message name='getCatalogResponse'>
<part name='Result' type='xsd:string'/>
</message>
<portType name='CatalogPortType'>
<operation name='getCatalogEntry'>
<input message='tns:getCatalogRequest'/>
<output message='tns:getCatalogResponse'/>
</operation>
</portType>
<binding name='CatalogBinding' type='tns:CatalogPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='getCatalogEntry'>
<soap:operation soapAction='urn:localhost-catalog#getCatalogEntry'/>
<input>
<soap:body use='encoded' namespace='urn:localhost-catalog'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:localhost-catalog'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>
<service name='CatalogService'>
<port name='CatalogPort' binding='CatalogBinding'>
<soap:address location='http://localhost/soap/soap-server.php'/>
</port>
</service>
</definitions>
soap-server.php
<?php
function getCatalogEntry($catalogId)
{
if ($catalogId == 'catalog1')
{
$first = "<html><head><title>Catalog</title></head>
<body>
<table>
<tr>
<th>CatalogId</th>
<th>Journal</th>
<th>Section</th>
<th>Edition</th>
<th>Title</th>
<th>Author</th>
</tr>
<tr>
<td>catalog1</td>
<td>IBM developerWorks</td>
<td>XML</td>
<td>October 2005</td>
<td>JAXP validation</td>
<td>Brett McLaughlin</td>
</tr>
</table>
</body>
</html>";
return $first;
}
elseif ($catalogId == 'catalog2')
{
$second = "<html><head><title>Catalog</title></head>
<body>
<table>
<tr>
<th>CatalogId</th>
<th>Journal</th>
<th>Section</th>
<th>Edition</th>
<th>Title</th>
<th>Author</th>
</tr>
<tr>
<td>catalog2</td>
<td>IBM developerWorks</td>
<td>XML</td>
<td>July 2006</td>
<td>The Java XPath API</td>
<td>Elliotte Harold</td>
</tr>
</table>
</body>
</html>";
return $second;
}
}
ini_set("soap.wsdl_cache_enabled", false);
$server = new SoapServer("http://localhost/soap/catalog.wsdl");
$server->addFunction("getCatalogEntry");
$server->handle();
?>
soap-client.php
<?php
try
{
$client = new SoapClient("http://localhost/soap/catalog.wsdl");
$catalogId = 'catalog1';
$response = $client->getCatalogEntry($catalogId);
}
catch (SoapFault $fault)
{
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
var_dump($response);
?>
perfect, just what I need. I’ll work through the tutorial now. One that I havent seen.
but why is it that all the articles on web services on the web seem so dated? Am I referring to it incorrectly? or has it been surpassed by other methods?
I’m sure I’m looking in the wrong places and I’m going to find a whole world of information just around the corner… 
Yes, most of what I could find was dated too. The most recent article I’ve found, but haven’t been able to try as I don’t have Silverlight, is Silverlight and PHP, Part 2: Creating a Simple Twitter Client July 8, 2010
thanks for your helps on this. I have managed to get your example working, proving that it does work on my server. So it must be me!! 
I have some more questions now so I’ll start a new thread.