NuSoap http://sourceforge.net/projects/nusoap/<?php // Pull in the NuSOAP code require_once('lib/nusoap.php');// Define the method as a PHP function function hello($name) { return 'Hello, '.$name; }//echo '<pre>';print_r($_SERVER);echo '</pre>'; $_SERVER['HTTPS'] = isset($_SERVER['HTTPS']) ? "on" : "off"; // Create the server instance $server = new soap_server(); // Initialize WSDL support $server->configureWSDL('hellowsdl', 'urn:hellowsdl'); // Put the WSDL schema types in the namespace with the tns prefix $server->wsdl->schemaTargetNamespace = 'urn:hellowsdl'; $soap_defencoding = 'ISO-8859-1'; $server->soap_defencoding='ISO-8859-1'; // Register the method to expose $server->register('hello', // method name array('name' => 'xsd:string'), // input parameters array('return' => 'xsd:string'), // output parameters 'urn:hellowsdl', // namespace 'urn:hellowsdl#hello', // soapaction 'rpc', // style 'encoded', // use 'Says hello to the caller' // documentation );// 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); ?>
如果没有wsdl,但是你知道web service的接口的话,也同样可以进行通信。通信无非就是xml文本,只要格式符合web service的要求即可。
uri一般作为命名空间使用。
// Pull in the NuSOAP code
require_once('lib/nusoap.php');// Define the method as a PHP function
function hello($name) {
return 'Hello, '.$name;
}//echo '<pre>';print_r($_SERVER);echo '</pre>';
$_SERVER['HTTPS'] = isset($_SERVER['HTTPS']) ? "on" : "off";
// Create the server instance
$server = new soap_server();
// Initialize WSDL support
$server->configureWSDL('hellowsdl', 'urn:hellowsdl');
// Put the WSDL schema types in the namespace with the tns prefix
$server->wsdl->schemaTargetNamespace = 'urn:hellowsdl';
$soap_defencoding = 'ISO-8859-1';
$server->soap_defencoding='ISO-8859-1';
// Register the method to expose
$server->register('hello', // method name
array('name' => 'xsd:string'), // input parameters
array('return' => 'xsd:string'), // output parameters
'urn:hellowsdl', // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Says hello to the caller' // documentation
);// 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);
?>