Help using php 5 proxy classes to create webservice
Posted: Tue Jun 16, 2009 5:55 am
I'm currently working on a project which requires the use of php proxy classes which were generated based on a wsdl file, the tool I used was wsdl2phpInterpreter.
I am more or less new to php and soap and webservices. So I need a bit of advise and help with some of my queries relating to this project. I will explain what I want to do as best as possible.
I have the a php class called thinkWS which contains all the classes and fucntions based on my wsdl file.
I want to start by calling the request called: LoginAuthenticate which takes two paramenters as arguements, it takes a user_login_data and a customer_identifier. I will show the classes generated for these two arguements below, the only additional code in these classes is the getter and setters I added.
if (!class_exists("user_login_data")) {
/**
* user_login_data
*/
class user_login_data {
/**
* @access public
* @var string
*/
public $login;
/**
* @access public
* @var string
*/
public $password;
public function __construct($login, $password) {
$this->login = $login;
$this->password = $password;
}
public function setLogin($login){
$this->login = $login;
}
public function setPassword($password){
$this->password = $password;
}
public function getLogin(){
return $this->login;
}
public function getPassword(){
return $this->password;
}
}}
if (!class_exists("customer_identifier")) {
/**
* customer_identifier
*/
class customer_identifier {
/**
* @access public
* @var integer
*/
public $customer_id;
/**
* @access public
* @var string
*/
public $login;
/**
* @access public
* @var string
*/
public $password;
public function __construct($login, $password) {
$this->login = $login;
$this->password = $password;
}
public function setCustomerID($customer_id){
$this->customer_id = $customer_id;
}
public function getCustomerID(){
return $this->customer_id;
}
public function setLogin($login){
$this->login = $login;
}
public function setPassword($password){
$this->password = $password;
}
public function getLogin(){
return $this->login;
}
public function getPassword(){
return $this->password;
}
}}
Now the I have a the class which extends the soapclient called ThinkWS which has a class map with all the classes generated from the wsdl and then all the functions required for my webservice.
this is the beginning of the class
class ThinkWS extends SoapClient {
/**
* Default class map for wsdl=>php
* @access private
* @var array
*/
private static $classmap = array(
"ZZMoney" => "ZZMoney",
"ZZBoolean" => "ZZBoolean",
"ZZCustomerRole" => "ZZCustomerRole",
"user_login_data" => "user_login_data",
"customer_identifier" => "customer_identifier",
public function __construct($wsdl="Customized25.wsdl", $options=array()) {
foreach(self::$classmap as $wsdlClassName => $phpClassName) {
if(!isset($options['classmap'][$wsdlClassName])) {
$options['classmap'][$wsdlClassName] = $phpClassName;
}
}
parent::__construct($wsdl, $options);
}
/**
* Checks if an argument list matches against a valid argument type list
* @param array $arguments The argument list to check
* @param array $validParameters A list of valid argument types
* @return boolean true if arguments match against validParameters
* @throws Exception invalid function signature message
*/
public function _checkArguments($arguments, $validParameters) {
$variables = "";
foreach ($arguments as $arg) {
$type = gettype($arg);
if ($type == "object") {
$type = get_class($arg);
}
$variables .= "(".$type.")";
}
if (!in_array($variables, $validParameters)) {
throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
}
return true;
}
I need to call the request shown below:
public function LoginAuthenticate($mixed = null) {
$validParameters = array(
"(login_authenticate_request)",
);
$args = func_get_args();
$this->_checkArguments($args, $validParameters);
return $this->__soapCall("LoginAuthenticate", $args);
}
Can I please get some help on how I can implement this, Help greatly apprechiated
Thanks
Sean
I am more or less new to php and soap and webservices. So I need a bit of advise and help with some of my queries relating to this project. I will explain what I want to do as best as possible.
I have the a php class called thinkWS which contains all the classes and fucntions based on my wsdl file.
I want to start by calling the request called: LoginAuthenticate which takes two paramenters as arguements, it takes a user_login_data and a customer_identifier. I will show the classes generated for these two arguements below, the only additional code in these classes is the getter and setters I added.
if (!class_exists("user_login_data")) {
/**
* user_login_data
*/
class user_login_data {
/**
* @access public
* @var string
*/
public $login;
/**
* @access public
* @var string
*/
public $password;
public function __construct($login, $password) {
$this->login = $login;
$this->password = $password;
}
public function setLogin($login){
$this->login = $login;
}
public function setPassword($password){
$this->password = $password;
}
public function getLogin(){
return $this->login;
}
public function getPassword(){
return $this->password;
}
}}
if (!class_exists("customer_identifier")) {
/**
* customer_identifier
*/
class customer_identifier {
/**
* @access public
* @var integer
*/
public $customer_id;
/**
* @access public
* @var string
*/
public $login;
/**
* @access public
* @var string
*/
public $password;
public function __construct($login, $password) {
$this->login = $login;
$this->password = $password;
}
public function setCustomerID($customer_id){
$this->customer_id = $customer_id;
}
public function getCustomerID(){
return $this->customer_id;
}
public function setLogin($login){
$this->login = $login;
}
public function setPassword($password){
$this->password = $password;
}
public function getLogin(){
return $this->login;
}
public function getPassword(){
return $this->password;
}
}}
Now the I have a the class which extends the soapclient called ThinkWS which has a class map with all the classes generated from the wsdl and then all the functions required for my webservice.
this is the beginning of the class
class ThinkWS extends SoapClient {
/**
* Default class map for wsdl=>php
* @access private
* @var array
*/
private static $classmap = array(
"ZZMoney" => "ZZMoney",
"ZZBoolean" => "ZZBoolean",
"ZZCustomerRole" => "ZZCustomerRole",
"user_login_data" => "user_login_data",
"customer_identifier" => "customer_identifier",
public function __construct($wsdl="Customized25.wsdl", $options=array()) {
foreach(self::$classmap as $wsdlClassName => $phpClassName) {
if(!isset($options['classmap'][$wsdlClassName])) {
$options['classmap'][$wsdlClassName] = $phpClassName;
}
}
parent::__construct($wsdl, $options);
}
/**
* Checks if an argument list matches against a valid argument type list
* @param array $arguments The argument list to check
* @param array $validParameters A list of valid argument types
* @return boolean true if arguments match against validParameters
* @throws Exception invalid function signature message
*/
public function _checkArguments($arguments, $validParameters) {
$variables = "";
foreach ($arguments as $arg) {
$type = gettype($arg);
if ($type == "object") {
$type = get_class($arg);
}
$variables .= "(".$type.")";
}
if (!in_array($variables, $validParameters)) {
throw new Exception("Invalid parameter types: ".str_replace(")(", ", ", $variables));
}
return true;
}
I need to call the request shown below:
public function LoginAuthenticate($mixed = null) {
$validParameters = array(
"(login_authenticate_request)",
);
$args = func_get_args();
$this->_checkArguments($args, $validParameters);
return $this->__soapCall("LoginAuthenticate", $args);
}
Can I please get some help on how I can implement this, Help greatly apprechiated
Thanks
Sean