WSDL Mode

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.

WSClient Options for WSDL Mode

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

WSClient Methods Related to WSDL Mode

WSClientProxy getProxy()

Returns a client proxy object which can be used to access a service endpoint conveniently using dynamic invocation.

WSClientProxy Class

WSClientProxy is a class that can be used as the proxy for invoking services.

Methods

mixed WSClientProxy::__call(string function_name, array arguments, array options)

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");
        

Writing a Service to use WSDL mode

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();