Próbuję zrobić prosty system WS z użycie NuSOAP. Ale mam problem z uruchomieniem najprostszego przykladu.

Oto kod servera:

  1. <?php
  2. // Pull in the NuSOAP code
  3. require_once('lib/nusoap.php');
  4.  
  5. // Create the server instance
  6. $server = new soap_server;
  7.  
  8. $server->configureWSDL('hello',$ns);
  9. $server->wsdl->schemaTargetNamespace=$ns;
  10.  
  11. // Register the method to expose
  12. // Note: with NuSOAP 0.6.3, only method name is used w/o WSDL
  13. $server->register(
  14. 'hello' // method name
  15. );
  16. // Define the method as a php function
  17. function hello($names) {
  18. for ($i = 0; $i < count($names); $i++) {
  19. $retval[$i] = 'Hello, ' . $names[$i];
  20. }
  21.  
  22. return $retval;
  23. }
  24. // Use the request to (try to) invoke the service
  25. $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
  26. $server->service($HTTP_RAW_POST_DATA);
  27. ?>



Oto kod klienta:

  1. <?php
  2. // Pull in the NuSOAP code
  3. require_once('lib/nusoap.php');
  4. // Create the client instance
  5. $wsdl='http://localhost/WS/server.php?wsdl';
  6. $client = new soapclientx('http://localhost/WS/server.php?wsdl');
  7. // Check for an error
  8. $err = $client->getError();
  9. if ($err) {
  10. // Display the error
  11. echo '<p><b>Constructor error: ' . $err . '</b></p>';
  12. // At this point, you know the call that follows will fail
  13. }
  14. // Call the SOAP method
  15. $names = array('Scott', 'Albert', 'Robert', 'Phyllis');
  16. $result = $client->call(
  17. 'hello',  // method name
  18. array('names' => $names) // input parameters
  19. );
  20. // Check for a fault
  21. if ($client->fault) {
  22. echo '<p><b>Fault: ';
  23. print_r($result);
  24. echo '</b></p>';
  25. } else {
  26. // Check for errors
  27. $err = $client->getError();
  28. if ($err) {
  29. // Display the error
  30. echo '<p><b>Error: ' . $err . '</b></p>';
  31. } else {
  32. // Display the result
  33. print_r($result);
  34. }
  35. }
  36. ?>


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:
  1.  
  2. 2006-06-21 23:03:14.481467 soapclientx: call: operation=hello, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=
  3. params=array(1) {
  4.  ["names"]=>
  5.  array(4) {
  6.    [0]=>
  7.    string(5) "Scott"
  8.    [1]=>
  9.    string(6) "Albert"
  10.    [2]=>
  11.    string(6) "Robert"
  12.    [3]=>
  13.    string(7) "Phyllis"
  14.  }
  15. }
  16. headers=bool(false)
  17. 2006-06-21 23:03:14.482615 soapclientx: serializing param array for operation hello
  18. 2006-06-21 23:03:14.483621 soapclientx: in serialize_val: name=names, type=, name_ns=, type_ns=, use=encoded
  19. value=array(4) {
  20.  [0]=>
  21.  string(5) "Scott"
  22.  [1]=>
  23.  string(6) "Albert"
  24.  [2]=>
  25.  string(6) "Robert"
  26.  [3]=>
  27.  string(7) "Phyllis"
  28. }
  29. attributes=bool(false)
  30. 2006-06-21 23:03:14.484500 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
  31. value=string(5) "Scott"
  32. attributes=bool(false)
  33. 2006-06-21 23:03:14.485380 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
  34. value=string(6) "Albert"
  35. attributes=bool(false)
  36. 2006-06-21 23:03:14.486484 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
  37. value=string(6) "Robert"
  38. attributes=bool(false)
  39. 2006-06-21 23:03:14.487697 soapclientx: in serialize_val: name=item, type=, name_ns=, type_ns=, use=encoded
  40. value=string(7) "Phyllis"
  41. attributes=bool(false)
  42. 2006-06-21 23:03:14.488636 soapclientx: wrapping RPC request with encoded method element
  43. 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/
  44. 2006-06-21 23:03:14.489979 soapclientx: headers:
  45. bool(false)
  46. 2006-06-21 23:03:14.490493 soapclientx: namespaces:
  47. array(0) {
  48. }
  49. 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/
  50. 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>
  51. 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?