Próbuję zrobić prosty system WS z użycie NuSOAP. Ale mam problem z uruchomieniem najprostszego przykladu.
Oto kod servera:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server;
$server->configureWSDL('hello',$ns);
$server->wsdl->schemaTargetNamespace=$ns;
// Register the method to expose
// Note: with NuSOAP 0.6.3, only method name is used w/o WSDL
$server->register(
'hello' // method name
);
// Define the method as a php function
function hello($names) {
for ($i = 0; $i < count($names); $i++) { $retval[$i] = 'Hello, ' . $names[$i];
}
return $retval;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ?
$HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA);
?>
Oto kod klienta:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$wsdl='http://localhost/WS/server.php?wsdl';
$client = new soapclientx('http://localhost/WS/server.php?wsdl');
// 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
$names = array('Scott', 'Albert', 'Robert', 'Phyllis'); $result = $client->call(
'hello', // method name
array('names' => $names) // input parameters );
// Check for a fault
if ($client->fault) {
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>'; } else {
// Display the result
}
}
?>
Server odpala się bez problemów. Natomiast klient wyrzuca mi komunikat:
Error: no transport found, or selected transport is not yet supported!
Debugowanie wyrzuca coś takiego:
2006-06-21 23:03:14.481467 soapclientx: call: operation=hello, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=
params=array(1) {
["names"]=>
array(4) {
[0]=>
string(5) "Scott"
[1]=>
string(6) "Albert"
[2]=>
string(6) "Robert"
[3]=>
string(7) "Phyllis"
}
}
headers=bool(false)
2006-06-21 23:03:14.482615 soapclientx: serializing param array for operation hello
2006-06-21 23:03:14.483621 soapclientx: in serialize_val: name=names, type=, name_ns=, type_ns=, use=encoded
value=array(4) {
[0]=>
string(5) "Scott"
[1]=>
string(6) "Albert"
[2]=>
string(6) "Robert"
[3]=>
string(7) "Phyllis"
}
attributes=bool(false)
2006-06-21 23:03:14.484500 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
value=string(5) "Scott"
attributes=bool(false)
2006-06-21 23:03:14.485380 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
value=string(6) "Albert"
attributes=bool(false)
2006-06-21 23:03:14.486484 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
value=string(6) "Robert"
attributes=bool(false)
2006-06-21 23:03:14.487697 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
value=string(7) "Phyllis"
attributes=bool(false)
2006-06-21 23:03:14.488636 soapclientx: wrapping RPC request with encoded method element
2006-06-21 23:03:14.489318 soapclientx: In serializeEnvelope length=303 body (max 1000 characters)=<ns8339:hello xmlns:ns8339="http://tempuri.org"><names xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[4]"><item xsi:type="xsd:string">Scott</item><item xsi:type="xsd:string">Albert</item><item xsi:type="xsd:string">Robert</item><item xsi:type="xsd:string">Phyllis</item></names></ns8339:hello> style=rpc use=encoded encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2006-06-21 23:03:14.489979 soapclientx: headers:
bool(false)
2006-06-21 23:03:14.490493 soapclientx: namespaces:
array(0) {
}
2006-06-21 23:03:14.491377 soapclientx: endpoint=, soapAction=, namespace=http://tempuri.org, style=rpc, use=encoded, encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2006-06-21 23:03:14.492031 soapclientx: SOAP message length=700 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><ns8339:hello xmlns:ns8339="http://tempuri.org"><names xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[4]"><item xsi:type="xsd:string">Scott</item><item xsi:type="xsd:string">Albert</item><item xsi:type="xsd:string">Robert</item><item xsi:type="xsd:string">Phyllis</item></names></ns8339:hello></SOAP-ENV:Body></SOAP-ENV:Envelope>
2006-06-21 23:03:14.492764 soapclientx: Error: no transport found, or selected transport is not yet supported!
Czy ktoś wie w czym problem?