A user can provide a WSDL (Web Services Description Language) file to obtain a proxy and invoke a service. This is a very convenient way of implementing a client.
The following options can be used to configure the WSDL mode on the client side.
Option | Data Type | Value Domain | Default Value | Description |
wsdl | string | this should be a URI or a filename | none | You can provide a WSDL file or a URL of the WSDL file for this option |
classmap | array | array of class names | none | maps some WSDL complex types to PHP classes. This option must be an array with WSDL types as keys and names of PHP classes as values. |
WSClientProxy is a class that can be used as the proxy for invoking services.
In the WSDL mode, you can simply call the operations defined in WSDL as functions of WSClientProxy. You can simply pass the arguments as an array or object of the class defined in class map.This may return one value or multiple values. If only one value is returned, it will be a simple value (e.g., a string or an integer). If multiple values are returned __call will return an associative array of named output parameters.
The following is a sample code demonstrating the use of WSClientProxy. Consider we have a WSDL which defines the operation "echoString" which echoes a given value.
$client = new WSClient(array("wsdl"=>"sample.wsdl")); $proxy = $client->getProxy(); $value = $proxy->echoString(array("Hello World"));
Option | Data Type | Value Domain | Default Value | Description |
wsdl | string | this should be a URI or a filename | none | You can provide a WSDL file or a URL of the WSDL file for this option |
classmap | array | array of class names | none | maps some WSDL complex types to PHP classes. This option must be an array with WSDL types as keys and names of PHP classes as values. |
By default, WSO2 WSF/PHP uses functions that accept a WSMessage instance as the argument for service functions. However, when using the WSDL mode on the server side this is not necessary. You can write the functions that will accept multiple arguments for functions. To specify the type of arguments that a particular function takes, there are two constant values defined as "WSMESSAGE" and "MIXED". When a function is specified as MIXED it means that it is a function that accepts arguments other than a WSMessage instance.
By default, when you specify the wsdl file to the service with the option "wsdl"=>"<wsdl file location>", the service object assumes that the operations defined for this particular service will accept multiple arguments.
Example:
function echoFunction($a) { return $a; } $operations = array("echoString" => "echoFunction"); $opParams = array("echoFunction"=>"MIXED"); $svr = new WSService(array("wsdl"=>"sample.wsdl", "operations" => $operations, "opParams"=>$opParams)); $svr->reply();