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 |
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. 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"=>"echo.wsdl")); $proxy = $client->getProxy(); $value = $proxy->echoString("Hello World");
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. For the WSDL mode on the server side, please use the MIXED type functions.
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();