$res); } /** * @param int $a * (xs:int) * @param int $b * (xs:int) * @return int $return * (xs:int) */ function addfunction($a,$b) { $c = $a+$b; return array('return' => $c); } /** * @param array of int $a * (xs:int) * @return int $return * (xs:int) */ function addarrayfunction($a) { $sum = 0; foreach ($a as $value) { $sum += $value; } return array('return' => $sum); } function get_pw($username) { $user_pass_mapping = array( "Raigama" => "RaigamaPW", "Alice" => "abcd!123", "Bob" => "wxyz!123", "Test" => "Test"); if(isset($user_pass_mapping[$username])){ $password = $user_pass_mapping[$username]; return $password; } else return NULL; } $operations = array("hello"=>"helloworld", "add" => "addfunction", "addarray" => "addarrayfunction"); $opParams = array( "helloworld"=>"MIXED", "addfunction" => "MIXED", "addarrayfunction" => "MIXED"); $actions = array( "http://www.test.net/hello" => "hello", "http://www.test.net/add" => "add", "http://www.test.net/addarray" => "addarray"); // Security options $security_options = array("useUsernameToken" => TRUE); $policy = new WSPolicy(array("security"=>$security_options)); $security_token = new WSSecurityToken(array("passwordCallback" => "get_pw", "passwordType" => "Digest")); // Create service with options $srv = new WSService(array("operations"=>$operations, "bindingStyle"=>"doclit", "opParams"=>$opParams, "policy" => $policy, "securityToken" => $security_token, "serviceName" => "Test_WS3", "actions" => $actions)); // Reply to requests $srv->reply(); ?>