Codehaus XFire

Documentation

Quicklinks

Developers

Sponsors

The following blog entry has an example of how to write a PHP client for a web service exposed using XFire:

http://arsenalist.com/2007/01/19/php-client-for-web-services/

To consume XFire services from PHP requires the document/literal style of SOAP.

The PHP below assumes this entry in your services.xml:

<service>
        <serviceClass>org.codehaus.xfire.test.Echo</serviceClass>
        <implementationClass>org.codehaus.xfire.test.EchoImpl</implementationClass>
        <style>document</style> <!-- default -->
        <use>literal</use> <!-- default -->
    </service>

Incidentally, enabling MTOM does not appear to work yet with PHP.

From PHP you'll need to specify this for your SOAP client

$client = new SoapClient(
                         'http://yourhost/servlet/services/Echo?wsdl',
                         array(
                               'trace' => 1,
                               'soap_version' => SOAP_1_1,
                               'style' => SOAP_DOCUMENT,
                               'encoding' => SOAP_LITERAL
                               )
                         );

document/literal style requires that the argument be a document, with you make by an associative array.  The response is also a document, in this case with one field, "out".

$response = $client->echo(array("in0" => "come back to me"));
$str = $response->out;
$str == "come back to me";

XFire does not support RPC/Encoding and PHP does not support wrapped document/literal, but they both do support RPC/Literal.

To use that, make this change to your services.xml:

<style>rpc</style>

and this to your PHP constructor:

'style' => SOAP_RPC,

Then you can make calls like this:

$echoed = $client->echo("come back to me");