Web Service call from a template

Author Message

Greg Lakomy

Tuesday 22 April 2008 7:55:47 pm

Is it possible?

I need to call a web sevice that returns XML data. Then, I need to parse it and spit it on a page.

What's the best way to do that?

Thanks,
Greg.

Developer
http://www.duoconsulting.com

Maxime Thomas

Tuesday 22 April 2008 11:32:32 pm

I guess the best is to use php-curl.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Piotrek Karaƛ

Wednesday 23 April 2008 12:13:05 am

I'd probably write my own template operator that consumes the service (using PHP) and then returns either the XML object itself or some sort of formatted data structure that leaves template operations easy. If multiple web services, the operator could take a service address etc...

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Xavier Gouley

Wednesday 23 April 2008 3:50:24 am

Hi Greg, Hi Max :)

It is done on a web site today, at work.
I used php-soap for Web Service (not curl) :
works pretty well for very complex Web Services, but for simple request/reponse, php-curl should be better I guess.

I prefer a fetch than an operator, must easier to pass parameters (in the hash), and a little faster to execute.

Good luck !

Xavier Gouley
http://www.gxapplications.com/eng_blog/GX-Admin-s-Blog/

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 11:44:25
Script start
Timing: Jan 18 2025 11:44:25
Module start 'layout'
Timing: Jan 18 2025 11:44:25
Module start 'content'
Timing: Jan 18 2025 11:44:26
Module end 'content'
Timing: Jan 18 2025 11:44:26
Script end

Main resources:

Total runtime0.8110 sec
Peak memory usage4,096.0000 KB
Database Queries64

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 589.0469152.6250
Module start 'layout' 0.00500.0024 741.671939.4453
Module start 'content' 0.00740.8022 781.1172634.2031
Module end 'content' 0.80960.0014 1,415.320312.4688
Script end 0.8110  1,427.7891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4070160.0002
Check MTime0.00130.1588160.0001
Mysql Total
Database connection0.00070.083210.0007
Mysqli_queries0.756093.2090640.0118
Looping result0.00080.0930620.0000
Template Total0.775195.620.3875
Template load0.00220.275220.0011
Template processing0.772895.289020.3864
Template load and register function0.00020.019110.0002
states
state_id_array0.00090.108510.0009
state_identifier_array0.00150.185420.0008
Override
Cache load0.00170.2140220.0001
Sytem overhead
Fetch class attribute can translate value0.00120.148840.0003
Fetch class attribute name0.00110.139370.0002
XML
Image XML parsing0.00190.229740.0005
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00110.1348290.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs