user590849
user590849

Reputation: 11765

how to make webservices in PHP that return data in XML?

how to make components to be added to already existing Joomla based website so that they can return XML when another system, like a phone makes a web request.

The generated content should have information embedded in the form of XML.

i have seen this happen in several places and was wondering if i wanted to start to learn to do the above how should i do it?

Also how is it actually done?

Upvotes: 1

Views: 333

Answers (1)

jcolebrand
jcolebrand

Reputation: 16035

This article pretty well sums it up entirely: http://sam.xnet.tk/post/15/php-soap-server-part-2/

Things to note:

  • You have to create/maintain the WSDL by hand, as is my understanding.
  • You have to not try and fight the framework. Just "return" as appropriate the data you want.
  • It should live outside the Joomla templates.
  • You should be using PHP5.

Example code from that article:

$classmap = array('Meeting'=>'Meeting');
$server = new SoapServer('soap.wsdl',array('classmap'=>$classmap));
$server->setClass("MySoapServer");
$server->handle();

class Meeting
{
    var $Location;
    var $Name;
    var $Importance;
    var $StartTime;
    var $Duration;
}

but really I suggest you read through all the code provided in that post example download.

Upvotes: 1

Related Questions