Joomla Web Services

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Web Services setting - Can I do this with J!'s XML-RPC?

Post by beanluc » Thu Feb 25, 2010 7:44 pm

I haven't been able to find any informative material about the "Enable Web Services" setting in the Global Configuration.

Obviously the setting enables Joomla's xmlrpc server.

Now what? All I have come across, describing how anyone uses it, is that Blogger publishers use the Blogger XML-RPC plugin to insert content into J!.

What about the stock plugin? It's not documented anywhere.

I want applications to connect to J! webservices and retrieve J! data. Does the XML-RPC server support this already? Or would I have to write a plugin?

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Joomla Web Services

Post by jlighthouse » Fri Mar 26, 2010 11:29 am

Good day the community,

Web Services are usually used to retain the communication between a remote server, when these services are hosted and a client web site. Often we may go to some site and in the side bar (or any other information layer) find a small window with links on the latest news from another site or weather forecasts.

This window named as widget or module or gadget. RSS feeds can be an example of using web services. Also we know that AJAX technology is used to communicate within the local server. Due to security risks we omit AJAX and use web services, if we want to get the data from another server.

Remote server, when the web services are installed uses its own API to describe the clients how to call the service. There are several technologies to work with web services - SOAP, REST, XML-RPC, JSON.

I have found a little about XML-RPC. Also I have found an idea to use php library nuSOAP to handle up the SOAP remote calls.

The first question is referred for experienced developers: which technology is better suit to Joomla?
Personally, I want to try XML-RPC, but maybe it will be deprecated as far as this article says.

I have found the nice plugin to look into when writing my own plugin for one of the widgets I'm going to create. I use Joomla site as web services remote server so that on any other site (client, not obviously Joomla) I could call some method of Joomla web services.

I would like to discuss all the opportunities of Joomla and its Web Services. When the work is done, I will share my code here.
Last edited by jlighthouse on Sat Mar 27, 2010 3:34 pm, edited 1 time in total.
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Fri Mar 26, 2010 4:55 pm

No answers so far...

Ok, I've created my simple XML-RPC plugin. The next question is concrete - how can I call some method from another client side?

I've found, that XML RPC should be accessed at: www.example.com/joomlasitepath/xmlrpc/index.php
But this does not secify the method name, so I'm stuck

Please, help. No one works with web services?
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Fri Mar 26, 2010 5:58 pm

Fine with me, I attached the plugin. I took the code from the book Mastering Joomla.

Then I tried to call add method from within the client and it failed. I'm trying to experiment, but fail each time. This because I have found the docs, which are not covered with live examples.

Here goes my code, which I'm trying from the view (then in the layout I want to echo the $result):

Code: Select all

		require_once (JPATH_ROOT . DS . 'libraries' . DS . 'phpxmlrpc' . DS . 'xmlrpc.php');
		$xmlrpc_client = new xmlrpc_client('/xmplrpc/index.php','serverurl',80);
//		$xmlrpc_client->setDebug(1);
		$xmlrpc_msg = new xmlrpcmsg('add', array(new xmlrpcval(5,'int'),new xmlrpcval(1,'int')));
		$xmlrpc_resp = $xmlrpc_client->send($xmlrpc_msg);
		if (!$xmlrpc_resp) {
    		$result = "<p>Could not connect to HTTP server.</p>";
		} elseif ($xmlrpc_resp->faultCode()) {
    			$result = "<p>XML-RPC Fault #" . $xmlrpc_resp->faultCode() . ": " .
        		$xmlrpc_resp->faultString();
			} else {
    			$struct = $xmlrpc_resp->value();
    			$sumval = $struct->structmem('add');
    			$sum = $sumval->scalarval();
    			$result = "<p>Sum: " . htmlentities($sum) ."</p>";
			}
   		$this->assign('result', $result);
Docs I have found here - xmlrpc for many languages.

Please, help
You do not have the required permissions to view the files attached to this post.
Last edited by jlighthouse on Sat Mar 27, 2010 3:34 pm, edited 1 time in total.
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

xmlrpc services - Documentation, PLEASE. Re: Joomla Web Serv

Post by beanluc » Fri Mar 26, 2010 6:09 pm

jlighthouse is experiencing the same frustration as myself.

And nobody responded to my own help request either:
http://forum.joomla.org/viewtopic.php?f=428&t=492664

Please: If documentation exists for Joomla!'s XMLRPC services, we have NOT been able to find it. And if documentation does not exist, please suggest how we're to be supported.

The use of Jooma's XMLRPC should not be this obscure. Thanks to anybody who can point the way or give a little attention.

User avatar
dam-man
Joomla! Exemplar
Joomla! Exemplar
Posts: 7961
Joined: Fri Sep 09, 2005 2:13 pm
Location: The Netherlands
Contact:

Re: Joomla Web Services

Post by dam-man » Fri Mar 26, 2010 6:30 pm

I would like information to, but also found nothing...
Robert Dam - Joomla Forum Moderator
Dutch Boards | Joomla Coding Boards | English Support Boards

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Fri Mar 26, 2010 8:29 pm

Let we have two sites A (obviously Joomla) and B, hosted on different physical computers.

Let's experiment together:
  • Please, download the plugin above. Install and enable it in the remote A site
  • Switch on Web Services option in Global Joomla Configuration in the same A site
  • Go to the site http://gggeek.raprap.it/debugger/, enter server address, port and path as below:
    address = ip address or domain name of A site like google.com or 243.23.12.9
    port = 80
    path = /xmlrpc/index.php
  • Click Execute button to the right, you will see the populated list of available methods on server http://site_A_address:80/xmlrpc/index.php
  • Find ArticleWidget.add method and click Describe button, after that click Generate method call stub code button
  • Copy the generated code and insert it inside one of the forms of site B. I've gotten the next code:

    Code: Select all

    <?php
    /**
    * Add two numbers
    * @param float $p1
    * @param float $p2
    * @param int $debug when 1 (or 2) will enable debugging of the underlying xmlrpc call (defaults to 0)
    * @return array (or an xmlrpcresp obj instance if call fails)
    */
    function xmlrpc_ArticleWidget_add ($p1, $p2, $debug=0) {
    	$client =& new xmlrpc_client('/xmlrpc/index.php', 'site_A_address', 80);
    	$client->return_type = 'xmlrpcvals';
    	$client->setDebug($debug);
    	$msg =& new xmlrpcmsg('ArticleWidget.add');
    	$p1 =& new xmlrpcval($p1, 'double');
    	$msg->addparam($p1);
    	$p2 =& new xmlrpcval($p2, 'double');
    	$msg->addparam($p2);
    	$res =& $client->send($msg, 0, '');
    	if ($res->faultcode()) return $res; else return php_xmlrpc_decode($res->value());
    }
    ?>
I modified the above code to the following (used in the View):

Code: Select all

	require_once (JPATH_ROOT .DS. 'libraries' .DS. 'phpxmlrpc' .DS. 'xmlrpc.php');
	$xmlrpc_client = new xmlrpc_client('/xmplrpc/index.php','site_A_address',80);
	$xmlrpc_client->return_type = 'xmlrpcvals';
	$xmlrpc_client->setDebug(1);
	$xmlrpc_msg = new xmlrpcmsg('ArticleWidget.add');
	$p1 =& new xmlrpcval(5, 'double');
	$xmlrpc_msg->addparam($p1);
	$p2 =& new xmlrpcval(2, 'double');
	$xmlrpc_msg->addparam($p2);
	$xmlrpc_resp = $xmlrpc_client->send($xmlrpc_msg, 0, '');
	if (!$xmlrpc_resp) {
		$result = "<p>Could not connect to HTTP server.</p>";
	} elseif ($xmlrpc_resp->faultcode()) {
    		$result = "<p>XML-RPC Fault #". $xmlrpc_resp->faultcode() .": ". $xmlrpc_resp->faultString() ."</p>";
		} else {
//    			$struct = $xmlrpc_resp->value();
//    			$sumval = $struct->structmem('add');
//    			$sum = $sumval->scalarval();
//    			$result = "<p>Sum: " . htmlentities($sum) ."</p>";
    			$result = "<p>Sum: " . php_xmlrpc_decode($xmlrpc_resp->value()) ."</p>";
		}
	$this->assign('result', $result);
Then in the layout I just echoed the $result and I have gotten the error:

Code: Select all

XML-RPC Fault #2: Invalid return payload: enable debugging to examine incoming payload (XML error: Undeclared entity warning at line 150, column 8)
The debug mode showed me also a lot of information, what starts with:

Code: Select all

---GOT---
HTTP/1.1 200 OK
Date: Fri, 26 Mar 2010 19:45:01 GMT
Server: Apache/2.2.3 (Debian) DAV/2 PHP/5.2.0-8+etch15 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_perl/2.0.2 Perl/v5.8.8
X-Powered-By: PHP/5.2.0-8+etch15
P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Expires: Mon, 1 Jan 2001 00:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: c5956a69c45a8d74cedbeb987dc291ba=7f34120c4f60de6fa60dccc6a23b1e25; path=/
Last-Modified: Fri, 26 Mar 2010 19:45:02 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 1341
Connection: close
Content-Type: text/html; charset=utf-8
�������µWY�Û6~Îþ
Fyidî�9,ín�l�m�ìm%Ñwy¨åãßwFÔii�4E^lq�o�ÃáGrþôêýåÝßÞ�Ì)I>üñë»ëK
...(too much of this ugly stuff)..
---END---
HEADER: date: Fri, 26 Mar 2010 19:45:01 GMT
HEADER: server: Apache/2.2.3 (Debian) DAV/2 PHP/5.2.0-8+etch15 mod_ssl/2.2.3 OpenSSL/0.9.8c mod_perl/2.0.2 Perl/v5.8.8
HEADER: x-powered-by: PHP/5.2.0-8+etch15
HEADER: p3p: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
HEADER: expires: Mon, 1 Jan 2001 00:00:00 GMT
HEADER: cache-control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
HEADER: pragma: no-cache
HEADER: set-cookie: c5956a69c45a8d74cedbeb987dc291ba=7f34120c4f60de6fa60dccc6a23b1e25; path=/
HEADER: last-modified: Fri, 26 Mar 2010 19:45:02 GMT
HEADER: vary: Accept-Encoding
HEADER: content-encoding: gzip
HEADER: content-length: 1341
HEADER: connection: close
HEADER: content-type: text/html; charset=utf-8
COOKIE: c5956a69c45a8d74cedbeb987dc291ba=7f34120c4f60de6fa60dccc6a23b1e25

---INFLATED RESPONSE---[4146 chars]---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" >
... (and here goes the html code of the page, I guess homa page of site A) ...
I wish it could help somebody to find an issue
Last edited by jlighthouse on Sat Mar 27, 2010 3:33 pm, edited 1 time in total.
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Sat Mar 27, 2010 3:33 pm

I have decided to use JSON-RPC instead of XML-RPC

Let's change terminology from site A and site B to Server and Client

I want to create Server web services using php code (inside Joomla environment) that handles JSON-RPC requests like metaWeblog plugin that uses XML-RPC. On the other side, I want to create Client widget using javascript code (inside Client's web page).

I have found Clarifying Javascript-PHP communication using JSON-RPC article. The idea is what I really want - php Server, javascript Client and JSON-RPC transport protocol. But no Zend relative code!

There are many JSON-RPC implementations, but most of them are Language<->Language communications, not like php<->javascript one (different languages).

More docs:
JSON-RPC 2.0 Specification
pmrpc library - uses both javascript server and client
JSON-RPC PHP library - uses both php server and client
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Sat Mar 27, 2010 8:53 pm

Good for you, jlighthouse, you seem satisfied.

But, the question wasn't answered, so let's keep the thread open and let's underscore the clear hunger out here for documentation of the XML-RPC extension and capability that comes with Joomla!. [rhetoric]Why build it in if its use by developers is not going to be supported?[/rhetoric]

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Documentation, PLEASE. Re: Joomla Web Services

Post by beanluc » Sat Mar 27, 2010 10:00 pm

Here's what we've got:

http://docs.joomla.org/Xml-rpc
Extremely mis-titled document, it's not anything more than a copy of an email regarding architectural changes in J!1.6.

http://docs.joomla.org/How_to_implement ... _component
Not a how-to, a brief description of the two methodology options. No links to further investigation.

http://docs.joomla.org/Screen.plugins.e ... C_-_Joomla
"This Plugin provides the XML-RPC API to Joomla! users. It has no parameters." No links to "the XML-RPC API", no info about what users are expected to do with it, nor now.

http://docs.joomla.org/API_Execution_Or ... _Execution
"TODO".

/viewtopic.php?t=255651 - "170 - Implement MetaWeblog API to interact with Joomla! v 1.5 xml-rpc plugin"
Not documentation, nor "howto". Mostly just a play-by-play of someone's project progress, though the final product is available for scrutiny.

http://api.joomla.org/Unknown/xmlrpc_server.html
Regarding the implementation of Joomla's XML-RPC server. No XML-RPC API details.

http://developer.joomla.org/tutorials/1 ... lugin.html
Reveals that there is an onGetWebServices event. No XML-RPC API details.

If anyone can respond on any of the following subjects, please:
* How do we discover the API?
* How might one create in Joomla a XML-RPC client, for consuming another service?
* If Joomla XML-RPC server is supposed to provide an API into many Joomla tasks, why is every (all 2 or 3) practical XML-RPC tool a separate plugin (Movable Type, Blogger, un-released Component Update poller) - can't the native J! API service do anything? Well, what _can_ it do?

Thanks! Please: Treat me like I'm new. I am. I'm hoping to use the Joomla XML-RPC server in a first-ever project to write a XML-RPC client. Please help me with my education!

User avatar
mandville
Joomla! Master
Joomla! Master
Posts: 14799
Joined: Mon Mar 20, 2006 1:56 am
Location: The Girly Side of Joomla in Sussex

Re: Joomla Web Services

Post by mandville » Sat Mar 27, 2010 11:25 pm

i think if you bombard this link (listed at the top of the forum)
"Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum. "
with your version that you are writing for you may get a lead on what your doing.
HU2HY- Poor questions = Poor answer
Un requested Help PM's will be reported, added to the foe list and possibly just deleted
{VEL Team Leader}{TM Auditor }{ Showcase & Security forums Moderator}

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Sun Mar 28, 2010 6:52 am

No, I'm not satisfied, I will not use Zend. If XML-RPC web service can be written as plugin like metaWeblog one, then JSON-RPC web service has not been yet presented. I have not enough experience to write it myself. So I think of some controller, which handles remote requests, but currently I can't make it working.
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 727
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: Joomla Web Services

Post by nailson_imgn » Mon Mar 29, 2010 1:59 pm

Hi everyone.

I'm not used to webservices via XML-RPC. Instead, I've been using SOAP for accessing 4 web services I need as client and it has been really easy to implement / edit / add features so far.
I use a generic XML PHP class ( there are plenty of them over the web ) with an extra method to get external data in the server side, using CURL or some other method, which I extend in order to add every service. So far, i just need to create a service class that overwrites / creates 1 or more setHeader and parseResponse functions and it's done. I really think it's worth a try.
However, if the XML-RPC can really be worth, I would like to learn how as well!

* How do we discover the API?
So far, I go into the API page, look for class page, then look for the file path in the top of the page.
Then I open the file folder and see the contents. Usually there's more files and some of them will most certainly have comments or docs which can be explored.
I'm sure that there are better ways, but this one works most times for me.

Also, a quick google search for XML-RPC shows a lot of relevant results. As a good starting point I read http://www.xmlrpc.com/ which seems to be a really usefull page with links to descriptions, examples, other docs and a lot more. Also looking for "XML-RPC vs. SOAP" brings up a lot of good articles.

Good luck, everyone.
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Thu Apr 08, 2010 7:06 pm

mandville wrote:i think if you bombard this link (listed at the top of the forum)
"Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum. "
with your version that you are writing for you may get a lead on what your doing.
Mandville,
instead of me applying for membership in a group which is intended for the Joomla product developers and not for Joomla users support, how about if we moderate/move this post to a Forum area which is intended for Joomla users support and not a forum which is intended to be (but actually is not) CLOSED to discussion?

Another idea I have is to lock this forum so that people can't continue to make this mistake daily, and make the notice about where to take discussions on this subject a lot more prominent, as well as additional clarity about precisely what the intended subject is.

Thanks for anything you can do to mitigate the daily pain - that of support-seekers who can't easily tell that this forum isn't active or appropriate, and that of core developers and moderators who get testy over users posting here. And also that of myself, who has not found any help on the subject of Jomla 1.5's XML-RPC API and server.

User avatar
mandville
Joomla! Master
Joomla! Master
Posts: 14799
Joined: Mon Mar 20, 2006 1:56 am
Location: The Girly Side of Joomla in Sussex

Re: Joomla Web Services

Post by mandville » Thu Apr 08, 2010 8:11 pm

i have made some "prods" lets see if they get a result.
HU2HY- Poor questions = Poor answer
Un requested Help PM's will be reported, added to the foe list and possibly just deleted
{VEL Team Leader}{TM Auditor }{ Showcase & Security forums Moderator}

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Thu Apr 08, 2010 10:55 pm

Hi, what are you trying to do? What do you want to do with the "stock plugin"?
Getting data out of Joomla? What data? What

Do you want to write your own code to get some data from a third party extension?
http://api.joomla.org/Unknown/xmlrpc_client.html
http://api.joomla.org/Unknown/xmlrpc_server.html
http://docs.joomla.org/Reference:System ... ebServices

As far as I know you can only manage the articles through XML-RPC.

To see which methods are available, it depends which plugins are enabled:
e.g. in the Joomla plugin you have the method joomla.searchSite

and in the blogger plugin you have the following methods:

blogger.getUsersBlogs
blogger.getUserInfo
blogger.getPost
blogger.getRecentPosts
blogger.getTemplate
blogger.setTemplate
blogger.newPost
blogger.deletePost
blogger.editPost

there are some system methods as well:
system.listMethods
system.methodHelp
system.methodSignature
system.multicall
system.getCapabilities

Is you questions is more about which parameter are needed for each method?

For the joomla plugin it is this one:

Code: Select all

	 @param	string	Target search string
	 @param	string	mathcing option, exact|any|all
	 @param	string	ordering option, newest|oldest|popular|alpha|category
For the blogger plugin it is this one:

Code: Select all

'blogger.getUsersBlogs' => getUserBlogs($appkey, $username, $password)
'blogger.getUserInfo' => getUserInfo($appkey, $username, $password)
'blogger.getPost' => getPost($appkey, $postid, $username, $password)
'blogger.getRecentPosts' => getRecentPosts($appkey, $blogid, $username, $password, $numposts)
'blogger.getTemplate' => getTemplate($appkey, $blogid, $username, $password, $templateType)
'blogger.setTemplate' => setTemplate($appkey, $blogid, $username, $password, $template, $templateType)
'blogger.newPost' => newPost($appkey, $blogid, $username, $password, $content, $publish)
'blogger.deletePost' => deletePost($appkey, $postid, $username, $password, $publish)
'blogger.editPost' => editPost($appkey, $postid, $username, $password, $content, $publish)
	
Please note that blogger.getTemplate and blogger.setTemplate are not implemented and will return a "not implemented" message.

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Fri Apr 09, 2010 1:27 am

Thanks, oofick, I've seen all of the above.
The api.j!.org references cover the methods for managing xml-rpc sessions and interactions, from the perspectives of Joomla as a client and a server.
The Blogger plugin is an implementation of a Joomla xml-rpc client for interacting with (at least parts of) Blogger's xml-rpc API.

So, here's what I'm missing, having seen all the above: Is there any implementation of Joomla functions via an xml-rpc API which other clients can interact with? What I expect from an xml-rpc API is, classes and methods available to local native program code can be exposed via xml-rpc so that remote programs can perform application functions as clients rather than as local processes. Naturally, authentication and authorization would be part of such an API as they're a crucial part of the system itself.

So, if I understand correctly that there's nothing here other than everything I've already seen, it suggests that nothing at all can be done with Joomla's xml-rpc services, without someone developing the plugin themselves in order to allow Joomla to "serve" its own API to clients. Is this about right?

Either way, the original question was
beanluc wrote:I haven't been able to find any informative material about the "Enable Web Services" setting in the Global Configuration.

Obviously the setting enables Joomla's xmlrpc server.

Now what? All I have come across, describing how anyone uses it, is that Blogger publishers use the Blogger XML-RPC plugin to insert content into J!.

What about the stock plugin? It's not documented anywhere.

I want applications to connect to J! webservices and retrieve J! data. Does the XML-RPC server support this already? Or would I have to write a plugin?
I guess to paraphrase it again now, the question begged is - does Joomla provide any actual webservices, or is the xml-rpc plugin nothing more than a means of making a webservice possible if we want to write one? To reiterate: The only implementations I've seen any kind of example of at all, are implementations of Joomla! as a xml-rpc client to other APIs. What are the xml-rpc server capabilities?

Thanks a lot, I appreciate the help. Even if it's nothing more than, "Yeah, that's right, it doesn't really work that way", well, that's helpful in and of itself. If there actually is an xml-rpc server API into Joomla tasks, that's even better.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Fri Apr 09, 2010 8:33 am

The plugins which come with Joomla by default cannot give you any data of a third party extension. You will have to write your own plugin for that.

Which stock plugin are you referring to? Does that plugin implement any xml-rpc methods?

Moreover, Joomla includes a xml-rpc server. e.g. if you want to search for something on the site, you can also use the xmlrpc method joomla.searchSite, and the blogger methods are using the xmlrpc-server as well.

So in that way, yes, the xmlrpc-server in joomla allows you to receive data. And it has the great flexibility to allow you to choose (by writing a plugin) which data you want to supply.

To answer your "Now what" question, lets take the example of the sitesearch:
  1. Enable the XML-RPC server
  2. Enable the Joomla plugin (type xmlrpc)
  3. create a php file to access the webservice (it doesn't need to be on the same server)
  4. download the phpxmlrpc client library (or link it to the one in joomla)
  5. copy the following code into it:

    Code: Select all

    <?php
    
    include(dirname(__FILE__).'/libraries/phpxmlrpc/xmlrpc.php');
    
    /**
    * Searches a remote site.
    * @param string $p1
    * @param string $p2
    * @param int $debug when 1 (or 2) will enable debugging of the underlying xmlrpc call (defaults to 0)
    * @return string (or an xmlrpcresp obj instance if call fails)
    */
    function xmlrpc_joomla_searchSite ($p1, $p2, $debug=0) {
    $client =& new xmlrpc_client('/xmlrpc/index.php', 'www.your-server.com', 0);
    $client->return_type = 'xmlrpcvals';
    $client->setDebug($debug);
    $msg =& new xmlrpcmsg('joomla.searchSite');
    $p1 =& new xmlrpcval($p1, 'string');
    $msg->addparam($p1);
    $p2 =& new xmlrpcval($p2, 'string');
    $msg->addparam($p2);
    $res =& $client->send($msg, 0, '');
    if ($res->faultcode()) return $res; else return php_xmlrpc_decode($res->value());
    }
    ?>
    <pre>
    <?php
    print_r( xmlrpc_joomla_searchSite('test','ALL'));
    ?> 
    </pre>
    
  6. access that php file with your browser
Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Fri Apr 09, 2010 4:57 pm

Olaf, thanks a lot for that, now we're getting somewhere, because I can now illustrate extremely clearly what I've been looking for.

Before I go there, though, I'll answer your questions
Which stock plugin are you referring to? Does that plugin implement any xml-rpc methods?
The "stock plugin" is just the Joomla xml-rpc plugin you named in step 2 of your instructions. Does that plugin implement any xml-rpc methods? If by xml-rpc methods you mean methods for executing xml-rpc communications, then, clearly, yes. If by xml-rpc methods you mean methods like joomla.searchSite, well, this is what I've been looking for, and the apparent answer is Yes.

So my question has been:
How are Joomla API calls implemented in the xml-rpc server? I now have precisely one example of a Joomla function - searchSite. I would like to know what all available such methods are - this is what I mean when I ask for "documentation". I wasn't looking for a how-to about writing an xml-rpc client in general, I was looking for, What can I expect the client to be able to do, and how do I tell the client what to request?

We're calling it a "webservices", but it isn't self-describing, as far as I've been able to tell - no WSDL, no SOAP, and this is where my blockage is.

Again, I very much appreciate your help, thanks!

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Fri Apr 09, 2010 5:44 pm

Well, i listed all the available methods, which are installed by default (if both plugins are enabled.) above:
  • joomla.searchSite
  • blogger.getUsersBlogs
  • blogger.getUserInfo
  • blogger.getPost
  • blogger.getRecentPosts
  • blogger.getTemplate
  • blogger.setTemplate
  • blogger.newPost
  • blogger.deletePost
  • blogger.editPost
  • system.listMethods
  • system.methodHelp
  • system.methodSignature
  • system.multicall
  • system.getCapabilities
Each one of those methods allows you to get some data of the system and each function has it is own description as well, similar to the WDSL one, but it is a little harder to get.

in the code above I have used "new xmlrpcmsg('joomla.searchSite')" but you can obviously replace joomla.searchSite with different methods as well, e.g "system.listMethods", so the code below would return the full list of methods, with a description of each one:

Code: Select all

<?php

include(dirname(__FILE__).'/libraries/phpxmlrpc/xmlrpc.php');

/**
* Searches a remote site.
* @param string $p1
* @param string $p2
* @param int $debug when 1 (or 2) will enable debugging of the underlying xmlrpc call (defaults to 0)
* @return string (or an xmlrpcresp obj instance if call fails)
*/
function xmlrpc_joomla_listMethods ($debug=0) {
$client =& new xmlrpc_client('/xmlrpc/index.php', 'www.yourserver.com', 0);
$client->return_type = 'xmlrpcvals';
$client->setDebug($debug);
$msg =& new xmlrpcmsg('system.listMethods');
$res =& $client->send($msg, 0, '');
if ($res->faultcode()) return $res; else return php_xmlrpc_decode($res->value());
}

function xmlrpc_joomla_methodHelp ($p1,$debug=0) {
$client =& new xmlrpc_client('/xmlrpc/index.php', 'www.yourserver.com', 0);
$client->return_type = 'xmlrpcvals';
$client->setDebug($debug);
$msg =& new xmlrpcmsg('system.methodHelp');
$p1 =& new xmlrpcval($p1, 'string');
$msg->addparam($p1);
$res =& $client->send($msg, 0, '');
if ($res->faultcode()) return $res; else return php_xmlrpc_decode($res->value());
}

foreach( xmlrpc_joomla_listMethods() as $p){
	echo "<h1>".$p."</h1>";
	echo xmlrpc_joomla_methodHelp($p);
	echo "<br />";
}
?> 
Keep in mind that the list can be very short if you don't have any xmlrpc plugins activated.

If both plugins are enabled your list should look like this:
joomla.searchSite
Searches a remote site.
# @return: string
# @param: string
# @param: string

blogger.getUsersBlogs
Returns a list of weblogs to which an author has posting privileges.
# @return: array
# @param: string
# @param: string
# @param: string

blogger.getUserInfo
Returns information about an author in the system.
# @return: struct
# @param: string
# @param: string
# @param: string

blogger.getPost
Returns information about a specific post.
# @return: struct
# @param: string
# @param: string
# @param: string
# @param: string

blogger.getRecentPosts
Returns a list of the most recent posts in the system.
# @return: array
# @param: string
# @param: string
# @param: string
# @param: string
# @param: int

blogger.getTemplate

# @return: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: string

blogger.setTemplate

# @return: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: string

blogger.newPost
Creates a new post and optionally publishes it.
# @return: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: boolean

blogger.deletePost
Deletes a post.
# @return: boolean
# @param: string
# @param: string
# @param: string
# @param: string
# @param: boolean

blogger.editPost
Updates the information about an existing post.
# @return: boolean
# @param: string
# @param: string
# @param: string
# @param: string
# @param: string
# @param: boolean

system.listMethods
This method lists all the methods that the XML-RPC server knows how to dispatch
# @return: array

system.methodHelp
Returns help text if defined for the method passed, otherwise returns an empty string
# @return: string
# @param: string

system.methodSignature
Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)
# @return: array
# @param: string

system.multicall
Boxcar multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details
# @return: array
# @param: array

system.getCapabilities
This method lists all the capabilites that the XML-RPC server has: the (more or less standard) extensions to the xmlrpc spec that it adheres to
# @return: struct
Olaf
Last edited by ooffick on Fri Apr 09, 2010 6:18 pm, edited 1 time in total.
Reason: Edit: I have added the parameters to the output (using the system.methodSignature method)
Olaf Offick - Global Moderator
learnskills.org

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Fri Apr 09, 2010 6:23 pm

Thanks a lot, it's clear to me now that writing a plugin is the way to access any Joomla functionality not provided through Blogger or system plugins.

It's also clear that the Blogger plugin is not a client to Blogger but a server into Joomla, using a non-Joomla API specification (the API spec which the plugin was designed for is Blogger's own "protocol").

I very much appreciate the attention and help, thanks again.

User avatar
mandville
Joomla! Master
Joomla! Master
Posts: 14799
Joined: Mon Mar 20, 2006 1:56 am
Location: The Girly Side of Joomla in Sussex

Re: Joomla Web Services

Post by mandville » Fri Apr 09, 2010 11:56 pm

i add my thanks to ooffick for stopping by and explaining..
HU2HY- Poor questions = Poor answer
Un requested Help PM's will be reported, added to the foe list and possibly just deleted
{VEL Team Leader}{TM Auditor }{ Showcase & Security forums Moderator}

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Sat Apr 10, 2010 6:43 pm

It seems that you have built XML-rpc webservice. Any information about JSON-rpc?
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Sat Apr 10, 2010 7:16 pm

jlighthouse wrote:It seems that you have built XML-rpc webservice. Any information about JSON-rpc?
What are you trying to do? Using the xmlrpc server with a javascript client?

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
jlighthouse
Joomla! Intern
Joomla! Intern
Posts: 78
Joined: Sun Feb 14, 2010 2:07 pm

Re: Joomla Web Services

Post by jlighthouse » Sat Apr 10, 2010 7:26 pm

Yes, javascript json-rpc client and php json-rpc server. I have found various json-rpc server-client solutions, but I can't implement them. Should I describe json-rpc server somehow? I can't receive the request from the client. Of course client and server are on the different computers.
Currently developing one of the few and free Joomla ticket system, called Lighthouse - http://extensions.joomla.org/extensions ... -desk/8098

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Sat Apr 10, 2010 8:10 pm

Well, javascript cross-site scripting restrictions could cause some problems with that.

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
beanluc
Joomla! Guru
Joomla! Guru
Posts: 922
Joined: Wed Mar 04, 2009 9:50 am
Location: Silicon Valley, CA, USA

Re: Joomla Web Services

Post by beanluc » Sat Apr 10, 2010 8:18 pm

JSON-rpc simply uses JSON for data transport instead of using XML for that. No cross-site scripting vulnerability, because the data objects are completely static - not executable, and, no cross-site scripting restrictions, because the JSON objects are not subject to browsers' jails because the data isn't flagged as .JS content-type and isn't transmitted inside .JS <script> blocks.

jlighthouse, it's looking like the answer to your question is that Joomla has no built-in facility for json-rpc. The only webservice is xml-based.

User avatar
ooffick
Joomla! Master
Joomla! Master
Posts: 11403
Joined: Thu Jul 17, 2008 3:10 pm
Location: Ireland
Contact:

Re: Joomla Web Services

Post by ooffick » Sat Apr 10, 2010 8:42 pm

Yes, Joomla doesn't have json-rpc interface, he would need to develop that.

Olaf
Olaf Offick - Global Moderator
learnskills.org

User avatar
TonyT
Joomla! Intern
Joomla! Intern
Posts: 51
Joined: Sat Apr 01, 2006 10:00 am
Location: Sydney, Australia

Re: Joomla Web Services

Post by TonyT » Sat May 22, 2010 12:09 am

In case you are still looking for working examples - Akeeba Backup (in JED) component and plugin is a very nice working implementation using of the Joomla XML-RPC server functionality.

TonyT
Piece of cake !... probably.

DVD_GR
Joomla! Apprentice
Joomla! Apprentice
Posts: 30
Joined: Fri Nov 03, 2006 1:12 pm

Re: Joomla Web Services

Post by DVD_GR » Wed Jul 21, 2010 10:23 pm

does anybody know if i can call a button of a component via xmlrpc ?
thanks a lot!!


Locked

Return to “Joomla! 1.5 Coding”